❔ Circle
// In Main (here), add code to case 5 of the switch.
// • Clear the screen.
// • Generate a random Point2D point with an x, y anywhere in the console. This point will be the center position of the circle.
// • Calculate a random radius – ensure that it will NOT extend the circle beyond the bounds of the console.
// • Use the point and radius to create a Circle instance with any color you want.
// • Call Draw on the Circle instance.
Console.Clear();
rnd = new Random();
int x = rnd.Next(0, Console.WindowWidth-1);
int y = rnd.Next(0, Console.WindowHeight-1);
Point2D point = new Point2D(x, y);
int radius = rnd.Next();
while(x + radius > Console.WindowWidth || y + radius > Console.WindowHeight || x - radius < 0 || y - radius < 0)
{
radius = rnd.Next(1, Console.WindowWidth - x);
}
Circle circle = new Circle(radius, point, ConsoleColor.Magenta);
circle.Draw();
break; // In Main (here), add code to case 5 of the switch.
// • Clear the screen.
// • Generate a random Point2D point with an x, y anywhere in the console. This point will be the center position of the circle.
// • Calculate a random radius – ensure that it will NOT extend the circle beyond the bounds of the console.
// • Use the point and radius to create a Circle instance with any color you want.
// • Call Draw on the Circle instance.
Console.Clear();
rnd = new Random();
int x = rnd.Next(0, Console.WindowWidth-1);
int y = rnd.Next(0, Console.WindowHeight-1);
Point2D point = new Point2D(x, y);
int radius = rnd.Next();
while(x + radius > Console.WindowWidth || y + radius > Console.WindowHeight || x - radius < 0 || y - radius < 0)
{
radius = rnd.Next(1, Console.WindowWidth - x);
}
Circle circle = new Circle(radius, point, ConsoleColor.Magenta);
circle.Draw();
break;its an assignment I already turned in but would like some feedback as to why my check for radius boundary has been very wonky, i still had exceptions being thrown for it being out of bounds on my screen.
