CS46A Spring 18

6A

The Java Sub Shop has only two types of meat for their subs: pastrami and chicken. They sell a 6 inch and a 12 inch version of each. The prices are in the table below. Customers can order extra meat which adds $1.50 to the price regardless of size. Write the class SubSandwich.

  6 inch 12 inch
chicken $5.50 $8.95
pastrami $6.95 $9.50

An int is used to represent the type of meat. 0 is chicken and 1 is pastrami. Define and use the constants below to avoid errors. This is a technique that is often used

SubSandwich has a constructor that takes three parameters.

If the type is other than chicken or pastrami, set the type to pastrami. (That is, if the type is not CHICKEN or PASTRAMI, set it to PASTRAMI. Do not test for 0 and 1 but rather use the constants)

If size is a number other than 6 or 12, set it to 12.

It also has methods

Use proper if structure and do not duplicate code in the branches

Provide Javadoc

For the draft, provide the instance variables, implement the constructor and getSize, isExtraMeat, and getType methods. Provide stub for getCost and setSize so that your class will compile with the tester. Provide all the Javadoc

6A draft:
6A final:

6B

Complete the class LoopyFun that contains the methods specified below. There is no constructor or instance variables.

Provide Javadoc for the methods

Note that there are 2 testers for the final version

For the draft, implement getPermutationCount and provide its Javadoc

6B draft:
6B final:

6C

Complete the class LoopyText which has a constructor that takes a String of text. Implement the following methods.

Provide Javadoc

For the draft, provide the instance variable, constructor, getText() and getUpperCase() methods along with the necessary Javadoc

6C draft:
6C final: