Question: In C# The following program attempts to override the Shape class (attached ) to create an Oval with a given center point, x-diameter, and y-diameter.
In C#
The following program attempts to override the Shape class (attached ) to create an Oval with a given center point, x-diameter, and y-diameter. Find and correct any errors.
public class Oval : Shape
int xdiam;
int ydiam;
public Oval(Point p, int ma, int mi)
xdiam = ma;
ydiam = mi;
public override void Draw(Graphics g)
g.FillEllipse(Brushes.Red, location.X-2*xdiam,
location.Y-2*ydiam, xdiam, ydiam);
public class Ex10_8 : Form
Shape s;
public Ex10_8() {
Size = new Size(300,200);
s = new Oval(new Point(100,100), 70, 30);
protected override void OnPaint(PaintEventArgs e)
Graphics g = e.Graphics;
static void Main()
Application.Run(new Ex10_8());
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
