Answered step by step
Verified Expert Solution
Question
1 Approved Answer
assignment5.java base code is all ive written please help import java.io.*; //to use InputStreamReader and BufferedReader import java.util.*; //to use ArrayList public class Assignment5 {
assignment5.java base code is all ive written please help
A pments, 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 uributes (should be protected: The following constructor method should be provided to initialize the instance variables. Please refer to the UML class diagrams for their parameter types, and return type Note: the following constructor does not include the TotalCout, it will be initialized to its default value 0.0 automatically. publie Summer Camp/String somet, String some location, double some Weekly Rate, int someNumberOrWeeks) The instance variables de location, weekly Rate, and numberor Wecks are initialized to the value of the first parameter, the second parameter, the third parameter, and the forth parameter respectively The following mutator method should be provided for instance variable the camp title Siria BetCampi) The Summer Camp also has an abstract methods (which should be implemented overridden by its child classes vold compute TotalCost) The following to String method should be provided: puble String String String method returns a string of the following format: wamy Teatre 570.00 Weekly Rate werk Total Cost 0.00 DebateCamp class DebateCamp is a subclass of Summer Camp class. It has the following tributes in addition to the inherited ones: Attribute am Attribute type Description materialFee doble some material fee for the debate cam propion booleas where it has a group discount or not The following constructor method should be provided: pable DebateCamp (String tid, String location, double rate, int weeks, double materiales, String discount) The constructor of the parent class should be called using the first second third and forth parameters to initialize its title, location, weeklyRale, number OrWecks, and the remaining parameters are wed to initialize materialer and group.count. If the parameter discount is yes, the instance variable groupDiscount should be set to me, and if it is no, groupDiscount should be set to fare. The following methods should be implemented: public void compute TotalCosts) This method should update its totalCost as follows. Its basic total cost is computed as weekly Rate number Or Wecks. If groupDiscount is trw, then it should get a 10% discount, i.e., weekly Rae numberOfWocis should be multiplied by (0.9). Then at last, the material Fee should be added to it. Also, the following method should be implemented puble String toString amcha m . . . .. .. .. .. . . . . .. .. .. . . MacBook Pro The following methods should be implemented: public void compute TotalCest) This method should update its totalCost as follows. Its basic total cost is computed as weekly Rae m beror Wecks. Il groupDiscount is true, then it should get a 10% discount, i.e., weekly Rate number ofWeeks should be multiplied by (0.9). Then at last, the materiale should be added to it. Also, the following method should be implemented: public String String The String method inherited from Summer Camp class should be used to create a new string, and display a Debate Cump's information using the following format(note that if group Discount is true, it should show you for Group Discount and it should show no otherwise): Camp Tile Debate Wet Material Fee Group $12.00 V This toString method should make use of the toString method of its parent class. Robot Camp amp class. It has the following attributes in addition to the inherited ones Ana Abup pable RoboCampString title, String location, debe rate, int weeks, double facility Fer, double compFee) public void completa public String to the The oring method inherited from Summer Camp class should be used to create a new string, and display a wavings account's information using the following format: labates Weekly Rae 4370.00 MacBook Pro SIRAAMATIES Camp Tin Voohotica Location WC 17 We are 570.00 Tool Cost 250.00 Fan For 330 This toString method should make use of the String method of the parent class Math Camp class MathCamp is a class of Summer Camp class. It has the following wribute in addition to the inherited on Attribute am Arbetetype Descrip The following constructor method should be provided: public MathCamp(String title, String location, double rate, int weeks, String test Talling) The contractar of the parent class should be called in the fint, second third and for permeten ton if it in na, t aking uld be set to be e is the location, weekly Rae and herWerks of the parametestaking is yes, the instance b e ing should be store and public void compute TotalCosta) public String total Camp Tile Vella Lection WCool20 Weekly R $5575 Total Conv30.00 This 10 Sering method should make use of the string method of the parent class Inaturnepatnesiutilicatinile nanainthiatelindikalestia niraminathari MacBook Pro The Summer Camparer class is a utility class that will be used to create an object of a child class of Summer Camp from apable string The Summer Camp Panels object will never be insta l imat have the following method: public static Summer Camp pare String Tom CampString line to Parse) The p ri m arne wearing in the following format Rota del campi o n For robotic wiltype RoboCamp openlocation Format wh atcamp type : location work ater i Fee competition ng Decamp WGLIO 30.6.-9.50 Camp Roc . Coor12:00-3:37.50-17.30 Macomp All.COOR130.65.75.4 This method will parse is string by using demel. pull out the token information, create a new object of its corresponding child class of the Summertimpass with his or the object, and return it to the calling method. They will always be present and always be either becamp. Robotics Campor Madyan can be lower c o pper case) You may add other methods to the child classes in order to make your life easiet , namely for the four In this assignment, download Asien ja 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 a win in the Assignments java Add Summer Camp, Compute Total Costs. Search for Summerlamp, and List Summer Camps All input and output ould be bundled here. The main pethod old wat by displaying this updated men in this exact format: Choice Action C AWAS Sumer Camp ompute Total Contin L ist Summer Campin Qeruit play He pain What action would you like to perform MacBook Pro Search for Samra C ine Alle MacBook Pro A pments, 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 uributes (should be protected: The following constructor method should be provided to initialize the instance variables. Please refer to the UML class diagrams for their parameter types, and return type Note: the following constructor does not include the TotalCout, it will be initialized to its default value 0.0 automatically. publie Summer Camp/String somet, String some location, double some Weekly Rate, int someNumberOrWeeks) The instance variables de location, weekly Rate, and numberor Wecks are initialized to the value of the first parameter, the second parameter, the third parameter, and the forth parameter respectively The following mutator method should be provided for instance variable the camp title Siria BetCampi) The Summer Camp also has an abstract methods (which should be implemented overridden by its child classes vold compute TotalCost) The following to String method should be provided: puble String String String method returns a string of the following format: wamy Teatre 570.00 Weekly Rate werk Total Cost 0.00 DebateCamp class DebateCamp is a subclass of Summer Camp class. It has the following tributes in addition to the inherited ones: Attribute am Attribute type Description materialFee doble some material fee for the debate cam propion booleas where it has a group discount or not The following constructor method should be provided: pable DebateCamp (String tid, String location, double rate, int weeks, double materiales, String discount) The constructor of the parent class should be called using the first second third and forth parameters to initialize its title, location, weeklyRale, number OrWecks, and the remaining parameters are wed to initialize materialer and group.count. If the parameter discount is yes, the instance variable groupDiscount should be set to me, and if it is no, groupDiscount should be set to fare. The following methods should be implemented: public void compute TotalCosts) This method should update its totalCost as follows. Its basic total cost is computed as weekly Rate number Or Wecks. If groupDiscount is trw, then it should get a 10% discount, i.e., weekly Rae numberOfWocis should be multiplied by (0.9). Then at last, the material Fee should be added to it. Also, the following method should be implemented puble String toString amcha m . . . .. .. .. .. . . . . .. .. .. . . MacBook Pro The following methods should be implemented: public void compute TotalCest) This method should update its totalCost as follows. Its basic total cost is computed as weekly Rae m beror Wecks. Il groupDiscount is true, then it should get a 10% discount, i.e., weekly Rate number ofWeeks should be multiplied by (0.9). Then at last, the materiale should be added to it. Also, the following method should be implemented: public String String The String method inherited from Summer Camp class should be used to create a new string, and display a Debate Cump's information using the following format(note that if group Discount is true, it should show you for Group Discount and it should show no otherwise): Camp Tile Debate Wet Material Fee Group $12.00 V This toString method should make use of the toString method of its parent class. Robot Camp amp class. It has the following attributes in addition to the inherited ones Ana Abup pable RoboCampString title, String location, debe rate, int weeks, double facility Fer, double compFee) public void completa public String to the The oring method inherited from Summer Camp class should be used to create a new string, and display a wavings account's information using the following format: labates Weekly Rae 4370.00 MacBook Pro SIRAAMATIES Camp Tin Voohotica Location WC 17 We are 570.00 Tool Cost 250.00 Fan For 330 This toString method should make use of the String method of the parent class Math Camp class MathCamp is a class of Summer Camp class. It has the following wribute in addition to the inherited on Attribute am Arbetetype Descrip The following constructor method should be provided: public MathCamp(String title, String location, double rate, int weeks, String test Talling) The contractar of the parent class should be called in the fint, second third and for permeten ton if it in na, t aking uld be set to be e is the location, weekly Rae and herWerks of the parametestaking is yes, the instance b e ing should be store and public void compute TotalCosta) public String total Camp Tile Vella Lection WCool20 Weekly R $5575 Total Conv30.00 This 10 Sering method should make use of the string method of the parent class Inaturnepatnesiutilicatinile nanainthiatelindikalestia niraminathari MacBook Pro The Summer Camparer class is a utility class that will be used to create an object of a child class of Summer Camp from apable string The Summer Camp Panels object will never be insta l imat have the following method: public static Summer Camp pare String Tom CampString line to Parse) The p ri m arne wearing in the following format Rota del campi o n For robotic wiltype RoboCamp openlocation Format wh atcamp type : location work ater i Fee competition ng Decamp WGLIO 30.6.-9.50 Camp Roc . Coor12:00-3:37.50-17.30 Macomp All.COOR130.65.75.4 This method will parse is string by using demel. pull out the token information, create a new object of its corresponding child class of the Summertimpass with his or the object, and return it to the calling method. They will always be present and always be either becamp. Robotics Campor Madyan can be lower c o pper case) You may add other methods to the child classes in order to make your life easiet , namely for the four In this assignment, download Asien ja 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 a win in the Assignments java Add Summer Camp, Compute Total Costs. Search for Summerlamp, and List Summer Camps All input and output ould be bundled here. The main pethod old wat by displaying this updated men in this exact format: Choice Action C AWAS Sumer Camp ompute Total Contin L ist Summer Campin Qeruit play He pain What action would you like to perform MacBook Pro Search for Samra C ine Alle MacBook Pro import java.io.*; //to use InputStreamReader and BufferedReader
import java.util.*; //to use ArrayList
public class Assignment5
{
public static void main (String[] args)
{
char input1;
String inputInfo = new String();
String line = new String();
boolean operation;
// ArrayList object is used to store SummerCamp objects
ArrayList summerCampList = new ArrayList();
try
{
printMenu(); // print out menu
// create a BufferedReader object to read input from a keyboard
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader (isr);
do
{
System.out.println("What action would you like to perform?");
line = stdin.readLine().trim();
input1 = line.charAt(0);
input1 = Character.toUpperCase(input1);
if (line.length() == 1)
{
switch (input1)
{
case 'A': //Add SummerCamp
System.out.print("Please enter some summer camp information to add: ");
inputInfo = stdin.readLine().trim();
/***********************************************************************************
*** ADD your code here to create an object of one of child classes of SummerCamp class
*** and add it to the summerCampList
***********************************************************************************/
break;
case 'C': //Compute Total Costs for all camps
/***********************************************************************************
*** ADD your code here to compute the total costs for each camp in the summerCampList.
***********************************************************************************/
System.out.print("total costs computed ");
break;
case 'D': //Search for SummerCamp
System.out.print("Please enter a summer camp title to search: ");
inputInfo = stdin.readLine().trim();
operation = false;
/***********************************************************************************
*** ADD your code here to search a summer camp with the entered title and set operation
*** to true or false based on its result
***********************************************************************************/
if (operation == true)
System.out.print("SummerCamp found ");
else
System.out.print("SummerCamp not found ");
break;
case 'L': //List SummerCamps
/***********************************************************************************
*** ADD your code here to print out all camp objects. If there is no camp,
*** print "no summer camp "
***********************************************************************************/
break;
case 'Q': //Quit
break;
case '?': //Display Menu
printMenu();
break;
default:
System.out.print("Unknown action ");
break;
}
}
else
{
System.out.print("Unknown action ");
}
} while (input1 != 'Q'); // stop the loop when Q is read
}
catch (IOException exception)
{
System.out.println("IO Exception");
}
}
/** The method printMenu displays the menu to a user **/
public static void printMenu()
{
System.out.print("Choice\t\tAction " +
"------\t\t------ " +
"A\t\tAdd SummerCamp " +
"C\t\tCompute Total Costs " +
"D\t\tSearch for SummerCamp " +
"L\t\tList SummerCamps " +
"Q\t\tQuit " +
"?\t\tDisplay Help ");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started