12A

Many people want to follow a low carbohydrate diet. In order to do that, they need to know how many carbohydrates are in the foods they choose.

Make a subclass Food of the Product class we created in class. Besides the description and price  inherited from ProductFood also has an instance variable carbs (an int). Do not redefine price and description variables. Call the super class to initialize them

Food has a methods:

Provide Javadoc.

For the draft, make Food a subclass of Product. Provide the new instance variable, carbs. Write the constructor that takes description, price, and carbs (updated 11/28/2017), in that order. Be sure to initialize all the instance variables. Provide getCarbs. Implement the the setCarbs and isLowCarb methods as stubs. Remember that if a stub's return type is boolean, it should return false. Do not include getDescription in the draft.

12A draft:
12A final:

12B

Write a subclass SpecialRectangle of the Rectangle class A SpecialRectangle has a special set of colors. It has a String instance variable called paintColor. Do not add any instance variables except the paintColor. You will get lose credit if you do.

Valid paintColors and their red, green, blue values are:

vanilla (255, 255, 248)
blue_green (204, 255, 255)
purple (159, 0, 197)
burnt_orange (227, 117, 00)

Provide two constructors:

Each constructor will need to set the paintColor instance variable and call the super class setColor() method so the SpecialRectangle will be drawn in the correct color.

Provide methods to set and get the paintColor.

For the draft, provide the instance variables and implement the constructor with 4 parameters. . Implement the getPaintColor() method. Code setPaintColor as a stub.

12B draft:
12B final:

12C

Animals need energy to move, which they get from eating food.

Create a class Animal with a constructor that takes no parameters and has an instance variable

private int energy;

When an animal is "born" it has no energy.

It has the methods

Notice there is no setEnergy method. Energy is only changed by eating or moving.

When an animal is "born" it has no energy.

It isn't realistic for animals to be able to gather infinite amounts of energy. Create a subclass ImprovedAnimal which has a cap on the amount of energy an animal can have. The constructor takes a parameter that sets a maximum for energy. If the amount the ImprovedAnimal eats would set its energy above the max, the energy level is only increased to the max.

For the final, Animal will not change, but you need to submit it.

Provide Javadoc for both classes.

For the draft, write the Animal class. Include Javadoc

12C draft:
12C final: