Programming Course in C# ¡Free!

Colored circle

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Expand the exercise (shapes + square), so that it can also store data about "Colored Circles":


Comments about the diagram:
  • The "color" must be an integer, not type "Color"
  • You must create two constructors, as shown
  • You must create also methods ToString, Scale, Move
  • Instead of "String getColors", create "int GetColor()"
  • Redefine GetPerimeter and GetArea
  • "Main()" must not be part of "ColoredCircle", but of the test program.

Output



Solution


using System;

class ColoredCircle : Circle
{
protected int color;
public ColoredCircle() 
{

}

public ColoredCircle(double dX,double dY,double dRadius,int color )
{
this.dX = dX;
this.dY = dY;
this.dRadius = dRadius;
this.color = color;
}

public void Move()
{

}

public void Scale()
{

}

public string ToString()
{
return "";
}

public int GetColor() 
{
return 0;
}

public void SetColor(int newColor)
{
color = newColor;
}

public override double Area() 
{
return 0;
}

public override double Perimeter()
{
return 0;
}
}