Part A. The Shell Oil company offers this deal to its customers:

Your task is to implement a class GasCreditCard with methods public void buyGas(double gallons), public double getSavings(), and public void resetMonth(). The second method returns the savings that have accrued until now, and the third method resets to a new month.

Draft: Just provide stubs for the methods.

netbrat draft | final

Part B. In the Rectangle class, add methods

Here, contains means that the second rectangle is entirely contained in the first. intersects means that the two rectangles have at least one point in common, but neither contains the other. isDisjointFrom means that they have no point in common.

For this exercise, we will assume that the points on all four edges belong to the rectangle.

Each of the methods should contain only a return statement. No other statements. No local variables.

public boolean method(Rectangle other)
{
   return someBooleanExpression;
}

Draft: Provide stubs for the methods, write javadoc, and implement contains.

netbrat draft | final

Part C. Modify the Person class to add methods

that test whether this person is the parent, grand parent, or sibling of the other person (that is, with the same father and mother). Be sure to handle the case of null ancestors (in which case all methods should return false).

Draft: Provide stubs for all methods, write javadoc, and implement isParent.

Each of the methods should contain only a return statement. No other statements. No local variables.

public boolean method(Rectangle other)
{
   return someBooleanExpression;
}

In your solution to isGrandParent, you must call the isParent method.

netbrat draft | final