【发布时间】:2021-03-16 18:46:16
【问题描述】:
所以我正在制作一个程序,它涉及 3 种不同的颜色值。
我想让程序从 4 个列表中为所有 3 个形状选择一种随机颜色,而不是设置颜色。虽然我似乎无法弄清楚。
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;
【问题讨论】:
-
那么你想要的是每次你初始化一个形状,让它有列出的颜色之一?
标签: c# random colors enumeration