CS49J

Remember not to create packages. Use the default package

11A

Implement a subclass of Product called Painting. A Painting has a String instance variable, artist, in addition to description and price. These paintings are framed prints not originals.

Provide the instance variable and methods

Provide Javadoc. Use @Override for the overridden getDescription method

Codecheck URL

11B

You are given a BankAccount class. You are to write two subclasses: TransactionAccount and InterestAccount

BankAccount:

This class is provided for you. It is different from earlier versions in that it requires a minimum balance of $1500. There is a $10.00 fee for any month where the ending balance is below the minimum balance. There is an endOfMonth method to handle end of month processing. Its subclasses will handle end of month processing differently.

TransactionAccount:

This account is a subclass of BankAccount. It has no minimum balance, but there is a charges for every transaction after a certain number of free transactions. At the current time, the number of free transactions is 4 and the charge is a $5.00 for every transaction after that amount. Both deposits and withdrawals are transactions. There is no charge to get the balance. The fees are subtracted during end of month processing. Define and use constants.

InterestAccount:

This is a subclass of BankAccount. The owner of the account can deposit or withdraw money at any point. The account earns 0.9% interest annually compounded monthly. Interest is paid on the ending balance during end of month processing. Use a constant for annual interest rate.

Provide Javadoc. You can use @Override for overridden methods

Codecheck URL

11C

You are given a class Critter which represents an animal. Critter class will be the superclass of a set of subclasses classes. A Critter has a weight and a position on a number line. The constructor initializes the position to 0 and sets the weight from the parameter. Critter has an ArrayList of Strings to keep a log of its activities. It has other methods which you can view here

You are to implement the following subclasses of Critter

ImpatientCritter: A ImpatientCritter is always in a hurry If  you tell an ImpatientCritter to move 5, it will actually move 10 steps. You will override the move method.

LethargicCritter: A LethargicCritter only has two activities: eat and sleep. When asked to move, it will either eat or sleep. A LethargicCritter is created hungry so the first time its move method is called, the LethargicCritter should eat. (and add the word "eat" to the history. The next time the move method is called, the LethargicCritter will sleep (and add the word "sleep" to the history). It will continue to alternate activities in this manner.

MulishCritter: A MulishCritter is very stubborn. It only moves every third time you tell it it move. You will override the move method. If you call the MulishCritter's move method 4 times, it will move the requested amount, not move, not move, move the requested amount. (The % operator is handy here)

Provide Javadoc. You can use @Override for overridden methods

Codecheck URL