Question: SUBJECT : JAVA OOP Given the following super class and subclasses: public abstract class Theme Park { String name; // customer's name String icNo; //

SUBJECT : JAVA OOP SUBJECT : JAVA OOP Given the following super class and subclasses: public

abstract class Theme Park { String name; // customer's name String icNo;

Given the following super class and subclasses: public abstract class Theme Park { String name; // customer's name String icNo; // customer's identification card number boolean member; // either member or nonmember of the // theme park //Methods: //default and normal constructor //accessors //toString() public abstract double calCharges();//calculate the charges public class Water Park extends Theme Park { String activity; // surfBeach, waterRide or other //Methods: //default and normal constructor //accessors //toString() public double calCharges() {...} } public class Wildlife Park extends Theme Park { String category; // child or adult boolean isTrain; //use train or not //Methods: //default and normal constructor //accessors //toString() public double calCharges() {...} The details of ticket charges are given in Table 5.1 and Table 5.2: Table 5.1 Details of ticket charges for Water Park Activity Cost (RM) Surf Beach 40.00 Water Rides 30.00 Other 15.00 Table 5.2 Details of ticket charges for Wildlife Park Category Cost (RM) Adult 35.00 Child 20.00 An extra RM5 will be charged if the customer uses the train for Wildlife Park. (9 marks) b) Write code fragments in the application / driver class that can perform the following tasks: (Assume all relevant methods have been defined in all classes involved) i) Declare an array of object named tp to store various types of theme park where the size of array is entered by the user. (2 marks) ii) Assuming data has been stored in this tp array; calculate and display the total charges of every Water Park and Wildlife Park ticket respectively. (5 marks) iii) Print the list of adult customers in the wildlife park and the total number of adults, followed by the list of child customers in the wildlife park and the total number of children. (8 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!