[Solved] CSE205 Assignment5

$25

File Name: CSE205_Assignment5.zip
File Size: 169.56 KB

SKU: [Solved] CSE205 Assignment5 Category: Tag:
5/5 - (1 vote)

The assignment number, your name, StudentID, Lecture day/time, and a class description need to be included at the top of each file/class.

A description of each method is also needed. Some additional comments inside of methods (especially for a main method) to explain code that are hard to follow should be written.

New Skills to be Applied

In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:

Inheritance

The protected modifier

The super Reference

Abstract class

NumberFormat/DecimalFormat ArrayList

Program Description Class Diagram:

In Assignment #5, you will need to make use of inheritance by creating a class hierarchy for summer camps.

SummerCamp is an abstract class, which represents the basic attributes of any summer camp. It is used

as the root of the summer camp hierarchy. It has the following attributes (should be protected):

Attribute name Attribute type Description
title String A title for a summer camp
location String A location for a summer camp
weeklyRate double some weekly Rate for a summer camp
numberOfWeeks int A number of weeks for a summer camp
totalCost double some total cost to be computed for a summer camp

The following constructor method should be provided to initialize the instance variables. Please refer to the UML class diagram for their parameter types, and return type.

public SummerCamp(iString someTitle, String someLocation, double someWeeklyRate, int someNumberOfWeeks)

The instance variables title, location, weeklyRate, and numberOfWeeks are initialized to the value of the first parameter, the second parameter, the third parameter, and the forth parameter respectively. totalCost should be initialized to 0.0.

The following mutator method should be provided for instance variable the camp title

String getCampTitle( )

The SummerCamp also has an abstract methods (which should be implemented by its child classes:

void computeTotalCosts( )

The following toString method should be provided:

public String toString()

toString method returns a string of the following format:


Camp Title:
ttRobotics4

Location:ttCoor172

Weekly Rate:tt$70.00

Weeks:ttt3

Total Cost:tt$0.00

You should make use of the NumberFormat class (in java.text package) to format the weekly rate and total cost. NumberFormat should be used with an object of Locale (in java.util.Locale, i.e., Locale usMoney = new Locale(en, US); ) by specifying to use the US currency.

DebateCamp class

DebateCamp is a subclass of SummerCamp class. It has the following attribute in addition to the inherited ones:

Attribute name Attribute type Description
materialFee double some material fee for the debate camp
groupDiscount boolean where it has a group discount or not

The following constructor method should be provided:

public DebateCamp (String title, String location, double rate, int weeks, double materialFee, String discount)

The constructor of the parent class should be called using the first, second, third, forth, and fifth parameters to initialize its title, location, weeklyRate, numberOfWeeks, materialFee. If the parameter discount is yes, the instance variable groupDiscount should be set to true, and if it is no, groupDiscount should be set to false. The following methods should be implemented:

public void computeTotalCosts( )

This method should update its totalCost as follows. Its basic total cost is computed as weeklyRate * numberOfWeeks. If groupDiscount is true, then it should get a 10% discount,

i.e., weeklyRate * numberOfWeeks should be multiplied by (0.9). Then its materialFee should be added to it.

Also, the following method should be implemented:

public String toString()

The toString() method inherited from SummerCamp class should be used to create a new string, and display a savings accounts information using the following format (note that if groupDiscount is true, it should show yes for Group Discount and it should show no otherwise):


Debate Camp:


Camp Title:ttDebateLevel5

Location:ttPSH153

Weekly Rate:tt$45.25

Weeks:ttt4

Total Cost:tt$0.00

Material Fee:tt$12.00

Group Discount:ttyes

This toString method should make use of the toString method of its parent class.

You should make use of the NumberFormat class (in java.text package) to format the weekly rate, total cost, and material fee. NumberFormat should be used with an object of Locale (in java.util.Locale, i.e., Locale usMoney = new Locale(en, US); ) by specifying to use the US currency.

RoboticsCamp class

RoboticsCamp is a subclass of SummerCamp class. It has the following attribute in addition to the inherited ones:

Attribute name Attribute type Description
facilityFee double some facility fee for the robotics camp
competitionFee double some competition fee for the robotics camp

The following constructor method should be provided:

public RoboticsCamp(String title, String location, double rate, int weeks, double facilityFee, double compFee)

The constructor of the parent class should be called using the first, second, third, forth, fifth, and sixth parameters to initialize its title, location, weeklyRate, numberOfWeeks, facilityFee competitionFee.

The following methods should be implemented:

public void computeTotalCost( )

This method should update its totalCost as follows. Its basic total cost is computed as weeklyRate * numberOfWeeks. Then itsfacilityFee and competitionFee should be added to it.

Also, the following method should be implemented:

public String toString()

The toString() method inherited from SummerCamp class should be used to create a new string, and display a savings accounts information using the following format:


Robotics Camp:


Camp Title:ttRobotics4

Location:ttCoor172

Weekly Rate:tt$70.00

Weeks:ttt3

Total Cost:tt$0.00

Facility Fee:tt$37.50

Competition Fee:t$17.50

This toString method should make use of the toString method of the parent class.

You should make use of the NumberFormat class (in java.text package) to format the weekly rate, total cost, facility fee, and competition fee. NumberFormat should be used with an object of Locale (in java.util.Locale, i.e., Locale usMoney = new Locale(en, US); ) by specifying to use the US currency.

MathCamp class

MathCamp is a subclass of SummerCamp class. It has the following attribute in addition to the inherited ones:

Attribute name Attribute type Description
testTaking boolean whether taking a test or not
The following constructor method should be provided: public MathCamp(String title, String location, double rate, int weeks, String testTaking)

The constructor of the parent class should be called using the first, second, third, and forth parameters to initialize its title, location, weeklyRate, numberOfWeeks. If the parameter testTaking is yes, the instance variable testTaking should be set to true, and if it is no, testTaking should be set to false.

The following methods should be implemented:

public void computeTotalCosts( )

This method should update its totalCost as follows. Its basic total cost is computed as weeklyRate * numberOfWeeks. If testTaking is true, $25 should be added to it.

Also, the following method should be implemented:

public String toString()

The toString() method inherited from SummerCamp class should be used to create a new string, and display a savings accounts information using the following format (note that if testTaking is true, it should show yes for Test Taking Discount and it should show no otherwise.):


Math Camp:


Camp Title:ttAlgebra1

Location:ttCoor120

Weekly Rate:tt$65.75

Weeks:ttt4

Total Cost:tt$0.00

Test Taking:ttyes

This toString method should make use of the toString method of the parent class.

You should make use of the NumberFormat class (in java.text package) to format the weekly rate and total cost. NumberFormat should be used with an object of Locale (in java.util.Locale, i.e., Locale usMoney = new Locale(en, US); ) by specifying to use the US currency.

SummerCampParser class

The SummerCampParser class is a utility class that will be used to create an object of a child class of SummerCamp class from a parsable string. The SummerCampParser class object will never be instantiated. It must have the following method:

public static SummerCamp parseStringToSummerCamp(String lineToParse)

The parseStringToSummerCamp methods argument will be a string in the following format: For a debate camp with its type DebateCamp type:title:location:weeklyRate:numberOfWeeks:materialFee:groupDiscount For a robotics camp with its type RoboticsCamp type:title:location:weeklyRate:numberOfWeeks:facilityFee:competitionFee

A real example of this string would be:

DebateCamp:Intro:WGHL101:30.50:6:9.50:no

OR

RoboticsCamp:Robotics4:Coor172:70.0:3:37.50:17.50

OR

MathCamp:Algebra1:COOR120:65.75:4:yes

This method will parse this string, pull out the information, create a new object of its corresponding child class of the SummerCamp class with attributes of the object, and return it to the calling method. The type will always be present and always be either DebateCamp, RoboticsCamp, or MathCamp. (It can be lower case or upper case) You may add other methods to the child classes in order to make your life easier.

Assignment 5 class

In this assignment, download Assignment5.java

(https://canvas.asu.edu/courses/44324/files/12294899/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294899/download?wrap=1) file by clicking the link, and use it for your assignment. You need to add code to this file. The parts you need to add are written in the Assignment5.java file, namely for the four cases Add SummerCamp, Compute Total Costs, Search for SummerCamp, and List SummerCamps.

All input and output should be handled here. The main method should start by displaying this updated menu in this exact format:

ChoicettAction

tt

AttAdd SummerCamp

CttCompute Total Costs

DttSeatch for SummerCamp

LttList SummerCamps

QttQuit

?ttDisplay Help

Next, the following prompt should be displayed:

What action would you like to perform?

Read in the user input and execute the appropriate command. After the execution of each command, redisplay the prompt. Commands should be accepted in both lowercase and uppercase. Add SummerCamp

Your program should display the following prompt:

Please enter some summer camp information to add:

Read in the information and parse it using the summer camp parser.

Then add the new object (created by summer camp parser) to the summer camp list.

Compute Total Costs

Your program should compute total costs for all summer camps created so far by calling computeTotalCosts method for each of them in the summer camp list.

After computing total costs, display the following:

total costs computed

Search for SummerCamp

Your program should display the following prompt:

Please enter a summer camp title to search:

Read in the string and look up the summer camp list, if there exists a summer camp object with the same summer camp title, then display the following:

SummerCamp found

Otherwise, display this:

SummerCamp not found

List SummerCamps

List all summer camps in the summer camp list. Make use of toString method defined in the child classes of the SummerCamp class.

A real example is looked like this:


Debate Camp:


Camp Title:ttDebateLevel5

Location:ttPSH153

Weekly Rate:tt$45.25

Weeks:ttt4

Total Cost:tt$0.00

Material Fee:tt$12.00
Group Discount:ttyes


Math Camp:


Camp Title:ttAlgebra1

Location:ttCoor120

Weekly Rate:tt$65.75

Weeks:ttt4

Total Cost:tt$0.00

Test Taking:ttyes

If there is no summer camp in the summer camp list (the list is empty), then display following:

no summer camp

Quit

Your program should stop executing and output nothing.

Display Help

Your program should re display the choice action menu.

Invalid Command

If an invalid command is entered, display the following line:

Unknown action

Test Cases

Download the following input files, and the following output files, and save them in the same directory as

Assignment5.java (https://canvas.asu.edu/courses/44324/files/12294899/download?wrap=1) (https://canvas.asu.edu/courses/44324/files/12294899/download?wrap=1) is located.

input1.txt (https://canvas.asu.edu/courses/44324/files/12294887/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294887/download?wrap=1)

input2.txt (https://canvas.asu.edu/courses/44324/files/12294888/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294888/download?wrap=1)

input3.txt (https://canvas.asu.edu/courses/44324/files/12294889/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294889/download?wrap=1)

input4.txt (https://canvas.asu.edu/courses/44324/files/12294891/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294891/download?wrap=1)

output1.txt (https://canvas.asu.edu/courses/44324/files/12294892/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294892/download?wrap=1)

output2.txt (https://canvas.asu.edu/courses/44324/files/12294893/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294893/download?wrap=1)

output3.txt (https://canvas.asu.edu/courses/44324/files/12294894/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294894/download?wrap=1)

output4.txt (https://canvas.asu.edu/courses/44324/files/12294895/download?wrap=1)

(https://canvas.asu.edu/courses/44324/files/12294895/download?wrap=1)

Error Handling

Your program should be robust enough to handle all test cases above.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE205 Assignment5
$25