vendredi 4 décembre 2020

How to make my program select a random color from C# opposed to a set color?

So im making a program and it involves color values for 3 different.

I want to make the program pick a random color from the list of 4 for all 3 shapes, opposed to having a set color. Though I can't seem to figure it out.

enum color
{

    Red,
    Green,
    Blue,
    Black
}

//abstract class "Shape" which has 3 methods pretaining to attributes of the shape.
abstract class Shape
{
    public abstract double getArea();
    public abstract double getPerimeter();
    public abstract color getColr();
}
//Triangle class which inherits the Shape methods
class Triangle : Shape
{
    public double s1;
    public double s2;
    public double s3;
    public color c = color.Red;



Aucun commentaire:

Enregistrer un commentaire