PPT Slide
Question 3 (15 points). Here is a specification for method drawOval, which appears in class Graphics.
// Draw an oval that is bounded by the rectangle with upper-left
// corner (x,y), width w, and height h
public void drawOval(int x, int y, int w, int h)
Fill in the body of the following method. Declare any additional (local) variables that you need.
// Draw a circle, using Graphics g, with center (x,y) and radius r
public void drawCircle(Graphics g, int x, int y, int r)
g.drawOval( ____________, ____________, ____________, ____________);
Question 4 (10 points). (a) Class C variables b and c contain values as shown below. C has two int fields, x and y. Draw a diagram showing the values of b, c and the objects they reference after execution of the assignment b= c; .
b and c before execution of b= c;
(b) Assume that variables b and c have values as shown above. Show what b and c contain after execution of b= new C (6, c.y); . Assume that the constructor for class C has the specification
// Constructor: Assign b1 to x and b2 to y
public C( int b1, int b2)
Question 5 (25 points). Consider the following definition of class Employee, with the bodies of methods elided (i.e. suppressed, struck out, omitted, left out of consideration).
Your task is to write a subclass ContractEmployee of Employee (an extension of Employee). The subclass should have fields to contain the daily rate of pay and the number of days worked during the year. Subclass ContractEmployee should have (1) a constructor, (2) its own toString method and (3) a method to change the number of days worked --you decide what the parameter of this method should be. The constructor of the subclass should have the following specification:
// Constructor: An employee named n with d days of work at s dollars per day
// (Of course, the constructor must initialize field pay)
public ContractEmployee (String n, int d, double s)