Programming Fundamentals Assignment 2 2019 Semester 21Programming Fundamentals 2019 Semester 2Assignment ChoicesWe the PF teaching team have allowed for assignment choices considering the diversity ofstudents in PF. Therefore you are required to select either Assignment 2A or Assignment 2Bconsidering your background, skills, aspirations and the type of learner you are (preferguided/independent learning). The table below outline aspects of both, but you should do yourown research before selecting one.Assignment 2A Assignment 2BAssignment 2A requires a deeper understanding of OO conceptsand the use of Collection classes (ArrayList, HashMap). Somebonus marks are allocated to challenge the students. This projectis suitable if you are an independent learner and love challenges oran advanced learner.Assignment 2B guides you step bystep to develop classes, subclasses,exceptions etc. You need not makeuse of Collection classes.Assignment 2A: Timetabling and Enrolment System (20 marks)1. ObjectiveThe main objective of this assignment is to familiarize you with object oriented design,programming, testing and refactoring. This assignment is better suited to those who have someprevious programming experience and are interested in the OO design aspects.2. Overview and AssumptionsThe Timetabling and Enrolment system is a standalone system to be used next semester in anew tertiary institution. At this stage, the admin-staff, the only user, will carry out all operationson behalf of students and staffs, and you are required to consider only one (next) semester. Thissystem should take into account courses, course offerings, staffs, students, lessons (tutorials andlectures) and venues. The use cases and the activity diagram for the system are shown in theappendix I and II.Note, only some of the courses will be offered each semester. Moreover, there can be at mostone offering for a course in a semester. Students can enrol up to 4 courses and you need notconsider the course prerequisites. Students however, cannot take two courses where thelectures are overlapping. Moreover a student cannot enrol into a course offering which hasalready reached the maximum number.Existing Courses, Staffs and VenuesDetails of Currently available courses in the school are as follows but not all these courses willbe offered this semester. Note each course can be uniquely identified based on Course ID.course1: “P101", "Programming 1", "Teach Basic Programming”course2: “P102", "Programming 2", "Teach Intermediate Programming”course3: “S101", "Software Engineering", "Teach UML and Modelling"course4: “WP1", "Web Programming", "Teach Web Technologies"course5: “UI1", "User Interface", "Teach UI Principles"course6: “Math","Discret Maths","Teach Maths needed for CS"course7: “Net1", "Networking","Teach networking principles"Programming Fundamentals Assignment 2 2019 Semester 22Details of Currently available Venues in the school are as follows. Note the capacity of venuesvaries. Clearly no two lessons can be held at the same time and the system should check for anyclashes. Venue can be used from 8.0 to 21.00."12.10.02",100,"Interactive""12.10.03",200,"Interactive""10.10.22",36,"Traditional""10.10.23",36,"Traditional"Currently all tutorials and lectures are taken by the staff from the school. The staff employeenumber, name, position and location are as follows:"e44556","Tim O'Connor","Lecturer","14.13.11""e44321","Richard Cooper","Professor","14.13.12""e54321","Jane Smith","Lecturer","14.13.13""e53457", "Isaac Newton", "Associate Professor", "14.13.14"Note you are free to add more course, venues and staffs for testing purpose.3. RequirementsYou are required to write a menu driven program that will use the existing courses, staffs andvenues described in section two. In the first phase, the menu driven program caters mainly tostaff and admin needs by allowing course offerings, lessons (lectures or tutorials) to be added aswell as assigning a specific staff to a lesson. It should also allow printing venue, course offeringand staff timetables. In the second phase, student specific menu options should be providedsuch as enrolling, withdrawing from course offerings and registering, deregistering fromtutorials and printing student timetables.Adding Course OfferingA course offering must be added before (lessons) lectures or tutorials can be added. Whencreating a course offering the maximum number of students must be specified. There can atmost be one course offering for a course (in a given semester).Adding Lessons for a Course OfferingThe lessons in the school are either lectures or tutorials. For a given course offering there canonly be one lecture though a lecture can last for many hours. For each lesson the start time, theduration and the venue must be specified. When adding lessons for a course offering the systemshould ensure no two lessons for a given course offering can overlap. Moreover the systemshould ensure the venue is not already used for other lessons. If a lecture is added, the systemshould ensure the venue capacity for the lecture is adequate for the maximum number ofstudents allowed in the course offering.Adding StaffStaff can be assigned only after lectures or tutorials are already added. Clearly a staff cannot betaking two different lessons at the same time and the system should check for any clashes andalert the user if such an attempt is made.Programming Fundamentals Assignment 2 2019 Semester 23Student Related FunctionalityEnrolling and Withdrawing StudentsThough prerequisites are not imposed at present, no student should be allowed to enrol in morethan 4 courses. Students can however, withdraw from a course before enrolling in another. Inthe current phase, you are not required to consider the census date. Students should not beenrolled into a course offering if it has already reached the maximum capacity. Moreover,students should not be allowed to enrol into two courses where the lecture times areoverlapping.Registering and Deregistering into TutorialsA student can register into a tutorial only if already enrolled in the course offering (it belongsto), the maximum capacity is not reached for the tutorial (36), and the selected lesson does notclash with any of the other tutorials for that student. Note a student is not required to registerinto a lecture, as any enrolled student is free to attend the lecture. Any attempt to register againinto a tute already registered, or deregister from a tutorial without first registering must resultin an error message being printed.Sub-Menu Options for Listing and TimetablesList StudentsThe system should allow admin to list the students in a course offering or a tutorial usingseparate menu options.View TimetablesThe system should allow timetables to be printed for each staff, each venue, each course offering(including all tutorials and lecture) and each student. Note the timetable need not be in arectangular grid unless you are aiming for usability and bonus marks.Program Specific RequirementsIn the first stage you are not required to consider the students (which adds to the complexity)and you may use the sample designs provided through the class and sequence diagrams. Youare however, required to come up with specific test cases (both negative and positive) todemonstrate all requirements are met. You are required to throw and catch the exceptionsClashException, PreExistException and CapacityException. A possible exception class forCapacityException is given below.public class CapacityException extends Exception {public CapacityException(String cause){super(cause);}}You may also come up with utility classes with static methods such as Math.max() if suchmethods promote reuse.Programming Fundamentals Assignment 2 2019 Semester 244. Rationale, Guidance and SuggestionsObject oriented programming helps to solve complex problems by coming up with a number ofdomain classes and associations. However, identifying meaningful classes and interactionsrequires a fair amount of design experience. Such experience cannot be gained by classroombasedteaching alone but must be gained through project experience. We have structured thisassignment (project) into two phases where student specific requirements can be deferred untilthe second phase. We have provided some initial UML design diagrams to foster the habit ofdesigning before commencing on implementation. Marks have been allocated in the finalsubmission for refactoring the design and code. You are also encouraged to use collections andexceptions, which simplify the implementation and error propagation. Repetition in thisassignment (4 timetables) is intended to make you use OO techniques that promote code reuse(inheritance, polymorphism, utility classes and methods).Use of Java CollectionsYou are encouraged to use collections such as ArrayList and HaspMap. ArrayList implements anarray, which can grow indefinitely. HashMaps allow an association to be created between keysand objects. Using such classes also reduce the amount of code required as they providemethods for retrieving required objects easily.ArrayList lessons = new ArrayList();lessons.add(new Lesson(…………));To extract the 4th elementLesson lesson4 = lessons.get(3); // index starts at 0You can use HashMap for storing objects, which have unique primary keys. For example,HashMap courses = new HashMap();To add a course we use :courses.put(new Course("P101", "Programming 1", "Teach Basic Programming"));To extract the course use:Course course = courses.get("P101"); // returns null if no such course in the mapSuggested Division of WorkPhase 1: Weeks (7 – 9)Work on individual classes and carry out some unit testing.Phase 2: Weeks (10 – 12)Integrate classes and test the functionalities. In addition, suggested student relatedfunctionalities below should be incorporatedFeature based Bonus MarksA. Allow all objects to be stored in a file and retrieved.B. Print all timetable in rectangular grid and save to a file (so that it can be printed)Programming Fundamentals Assignment 2 2019 Semester 25Appendix I Use Case for TimeTabling and Student Enrolment SystemIn the current version only the administrator will use the system to meet the staff and studentneeds. In the subsequent web-based version both staff and students will be allowed to interactdirectly.Add CourseOfferingAdd LessonAssign StaffEnrol in CourseOfferingWithdraw fromCourse OfferingRegister inTutorialDeregister fromTutorialList StudentsViewTimetableView StaffTimetableView VenueTimetableView StudentTimetableList Students inCourse OfferingList Students inTutorialAdd LectureAdd TutorialView CourseOfferingTimetableProgramming Fundamentals Assignment 2 2019 Semester 26Appendix II Activity-DiagramsAdd Course OfferingAdd Course Add Staff Add VenueAdd Lecture Add TutorialAssign Staff to LessonEnrol Student in Course OfferingRegister Student in TutorialProgramming Fundamentals Assignment 2 2019 Semester 27Appendix III Possible Class Diagram (Phase I ) TimeTabling & Student Enrolment SystemApplicationCourses: HashMap;Venues: HashMap;Staffs: HashMap;createCourseOffering()addLesson(String type)assignStaff()getCourse(cID:String):CoursegetStaff(sID:String):StaffCourseCourse(ID:String,name:String,purpose:String)courseId : Stringname : Stringobjective : StringcreateOffering()getOffering():CourseOfferingCourseOfferingmaxNum : intCourseOffering(maxNum:int,course:Course)addLecture(day:int,start:double,dur:double,ven:Venue)addTutorial(day:int,start:double,dur:double,ven:Venue)getLesson(day:int,start:int,end:int)checkClash(day:int, start)Lesson (abstract)Staffprivate String eNo;private String name;private String position;private String office;Staff(eNo: String, name: String,position: String, office:String)assign(Lesson lesson)exceptions=ClashException,PreExistExceptionTutorialTutorial(day:int,startHr:double,dur:double,venue:Venue,co:CourseOffering) exceptions=ClashExceptionVenuelocation: Stringcapacity: intpurpose: StringVenue(location:String,capacity:int, purpose:String)getLessons():ArrayListaddLesson(l:Lesson)LectureLecture(day:int,startHr:double,dur:double,venue:Venue,co:CourseOffering)exceptions=ClashException,CapacityException****0..1**startHour: doubleendHour: doubleday : intstaff: Staffvenue Venueco: CourseOfferingLesson(day:int,startHr:double,dur:double,venue:Venue,co:CourseOffering)exceptions=ClashExceptionsetStaff(staff:Staff)Programming Fundamentals Assignment 2 2019 Semester 28Appendix IV Possible Sequence Diagram: Add Course OfferingApplicationaddCourseOffering(ID)course = getCourse(ID)courseoffering =createOffering()Programming Fundamentals Assignment 2 2019 Semester 29Appendix V Possible Sequence Diagram: Add Tutorialapplicationcourse = getCourse(ID)courseoffering =getOffering()offeringaddTutorial(ID,day,start,dur,venue)addTutorial(day,start,dur,venue) checkClash(day,start,dur) // with other offering lessonsTutorialnew Tutorial(day,start,dur.venue)venuecheckClash(day,start,dur)// with other venue lessonsNote Tutorial Constructor will call thesuperclass (Lesson) constructorProgramming Fundamentals Assignment 2 2019 Semester 210Appendix VI Possible Sequence Diagram: Assign Lecturer to Lesson (Lecture or Tutorial)applicationcourse = getCourse(ID)courseoffering =getOffering()offeringaddTutorial(ID,day,start,dur,venue)lesson =getLesson(day,start)staff lessonsetStaff(staff)staff = getStaff(ID)assignLesson(lesson)checkClash(lesson)add(lesson)Programming Fundamentals Assignment 2 2019 Semester 211Assignment 2B: Vehicle Management System (20 marks)OverviewThis is a more prescriptive and incremental assignment suitable for those preferring clearguidance (instead of being open ended designs). You are required to complete Part A beforeproceeding to Part B, and similarly Part B before Part C.Part A: Develop a simple Vehicle class with three states ‘A’ (available), ‘S’ (servicing) and ’H’(hired) and methods. Your class must implement the required interface and test it with the dataprovided. In the second part the Vehicle class must be used for developing a simple application.(assignment to be demonstrated in week 8 to your lab assistant)Part B: Extend to PremiumVehicle implementing the overridden methods (which introduceadditional conditions for state transitions). You are also required to develop a menu-drivenapplication where both Vehicle and PremiumVehicle objects are stored in a common array,which must be manipulated in a polymorphic way when appropriate.serviceserviceComplete/set odometer readinghire / set Hired Date/Time and Hirerstatus = ‘S’Hire-complete / setodometer reading &&compute chargestatus = ‘A’status = ‘H’Vehicle classserviceserviceComplete/set odometer reading&& set last-servicehire [car not due for service] / set Hired Date/Time and Hirerstatus = ‘S’Hire-complete / setodometer reading&& compute chargebased on days ofhire and mileagestatus = ‘A’status = ‘H’PremiumVehicle classProgramming Fundamentals Assignment 2 2019 Semester 212In part C you are required to extend the menu-driven application developed in section Bincorporating file and exception handling. The customer details must also be included allowingspecific discounts. All Vehicle and subclass objects must be written to a file when program exitsand restored back when program commences. The methods should be made to throwappropriate exceptions when operation cannot be performedProgramming Fundamentals Assignment 2 2019 Semester 213Part A covers Chapters 1 to 6Section I Writing a Vehicle classYou are required to write a class named Vehicle to manage the hiring of vehicles. Therequirements are specified below.Instance VariablesProvide private instance variables to store the vehicle-ID, hirer-ID, description, status, dailyrate,odometer-reading and date/time of hire (use the DateTime class provided). Instancevariable for status of a car must be set to either 'A' (available), 'H'(hired) or 'S'(servicing).ConstructorProvide a constructor for the class that takes vehicle-ID, description, daily-rate and odometerreading to initialize the corresponding instance variables and to set the instance variable forstatus to 'A' (available for hire when first created) .public Vehicle(String vehicleID, String description, double dailyRate, int odometer)MethodsProvide methods to hire a vehicle, complete a hire, service a vehicle, return a vehicle back fromservice and to print the current state of the vehicle. The hire() must take as argument ID ofhirer. The date/time of hire should be set to current time which can be created using the defaultDateTime constructor (DateTime class described in later section). This method should returnfalse if an attempt is made to hire a vehicle which is currently being serviced (status ‘S’) oralready on hire (status ‘H’), otherwise(status ‘A’) the method should return true after setting thehirer ID (to the argument passed), the hire date (to current date), and status (to ‘H’ indicatinghired).public boolean hire(String hirerID) // called when car is hiredThe methods below are required for servicing a vehicle and for returning a vehicle back fromservice. These operations must return true only when the status of the vehicle are 'A' and 'S'respectively. Note the method serviceComplete(into odo) must set the current odometerreading.public boolean service() // called when car is sent for servicepublic boolean serviceComplete(int odo) // called when car is back from serviceProgramming Fundamentals Assignment 2 2019 Semester 214The hireComplete(int odo) must take one argument for odometer reading and return thecharges based on the duration of hire if the operation is successful, and a negative value (-1.0)otherwise. It must succeed only if the status is'H' and the odometer reading is greater thanodometer reading when car was hired. The duration-based charge can be computed multiplyingdaily-rate, by number of days. Assume that minimum rental duration is one day and the numberof days is computed based on 24 hours from the time of hire. For example, if Jack hires a car at9.00 am Monday morning and returns it on Tuesday 10.00 am, the hire duration should be set astwo days for the purpose of computing the charges.public double hireComplete(int odo) // called when car hire is completedThe print() must print the current date and time (using the getCurrentTime() method ofDateTime class) and the necessary vehicle details (ID, description, daily-rate, status, odometerreading) of Vehicle. If the vehicle is currently on hire, the ID of hirer and date/time of hire mustalso be printed.public void print()Override the toString method to return the String equivalentpublic Sting toString()This class should also provide accessors for all the instance variables (required for thesubclass).Programming Fundamentals Assignment 2 2019 Semester 215DateTime class providedclass DateTime{ private static long advance; // keeps tracks of any time advanceprivate long time;public DateTime() // constructor{ time = System.currentTimeMillis() + advance;}public long getTime() {return time; }// advances date/time by specified days, hours and mins for testing purposepublic static void setAdvance(int days, int hours, int mins){ advance = ((days * 24L + hours) * 60L) *60000L;}public String toString(){ long l = getTime();Date gct = new Date(l);return gct.toString();}public static String getCurrentTime() // returns current date/time{Date d = new Date(System.currentTimeMillis() + advance);return d.toString();}// returns difference in dayspublic static int diffDays(DateTime d2, DateTime d1){return (int) ( 1 + ( d2.getTime() - d1.getTime() )/(24L*60*60*1000));}}Programming Fundamentals Assignment 2 2019 Semester 216Test class and expected Output// Class to test the Vehicle class (provided)class TestVehicle{public static void main(String args[]){// Constructing a car currently available for hireVehicle v = new Vehicle("SAT123","Toyota Camry", 12.50, 100000);v.print();// Sending the car for serviceif ( v.service() == true)System.out.println("\nCar " + v.getID() + " is now sent for service ");elseSystem.out.println("\nWARNING: Car " + v.getID()+ " cannot be sent for service ");v.print();// Forward the time by 2 days (0 hours and 0 minutes)DateTime.setAdvance(2,0,0);// Attempt to hire a car on serviceif ( v.hire("User36784") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nWARNING: Car " + v.getID() + " could not be hired ");v.print();// Car returning from serviceif ( v.serviceComplete(100100) == true)System.out.println("\nCar " + v.getID() + " is now returned from service ");elseSystem.out.println("\nWARNING: Car " + v.getID()+ " cannot be sent returnned from service ");v.print();Programming Fundamentals Assignment 2 2019 Semester 217DateTime.setAdvance(4,0,0);// Attempt to hire the car which is now available for hireif ( v.hire("User36784") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nWARNING: Car " + v.getID() + " could not be hired ");v.print();DateTime.setAdvance(6,0,0);// Attempt to hire a car already on hireif ( v.hire("User9999") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nWARNING: Car " + v.getID() + " could not be hired ");v.print();// Attempt to return car from hiredouble val = v.hireComplete(121000);if ( val > 0.0 ){ System.out.print("\nCar " + v.getID() + " is returned by " + v.getHirer());System.out.println(" Charges = " + val);}elseSystem.out.println("\nWARNING:Car "+v.getID()+" could not be returned from hire ");v.print();DateTime.setAdvance(8,0,0);// Attempt to hire the car now availableif ( v.hire("User9999") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nWARNING: Car " + v.getID() + " could not be hired ");v.print();}}Programming Fundamentals Assignment 2 2019 Semester 218Expected OutputProgramming Fundamentals Assignment 2 2019 Semester 219Section II Using the Vehicle class(i) Declare an array named vehs that can store the references of up to 5 Vehicle objects.Create 5 Vehicle objects using its constructor passing the values specified below (for ID,description, daily-rate and odometer reading), storing their references in the array.SAM134, Toyota Camry 02, 45.00, 140000QKO156, Honda Accord 04, 65.0, 125000TUV178, Toyota Starlet 02, 35.00, 180000SAG132, Toyota Avalon 05, 52.0, 190000PRE342, Honda Civic 97, 35.00, 145000(ii) Display the ID and description of all the vehicles stored in the array.Hint: Access the Vehicle objects by iterating through the array of references vehs(using a loop). Extract ID and description of these objects using their accessors.(iii) Allow user to view the vehicles in the required price range (by specifying lower- andupper limits for daily rate). Display ID, description and daily-rate of all matchingvehicles. If no vehicles are found in the range, print an appropriate message.Hint: This requires you to loop through the array of references and select the requiredobjects using the accessor for daily-rate.(iv) Allow user to hire, complete-hire, service or complete-service a vehicle specifying thevehicle ID. If a vehicle is being hired prompt the user to enter the hirer-ID, and ifservice-complete or hire-complete options are selected prompt the user to enter theodometer reading as well.Hint: This requires looping through the array of references to locate the object withthe specified vehicle ID. If such an object is found then invoke the appropriatemethod on that object passing the required argument. Print appropriate errormessage if the object with specified ID cannot be found or if the requiredoperation cannot be performed.(v) Allow user to repeat the step 4, using a do while loop. The loop should be repeated, aslong as user responds positively to the prompt, “Any more transactions?”.(vi) Print the final details of all the vehicle objects using a for loop and the print() method.Programming Fundamentals Assignment 2 2019 Semester 220Part BSection I : Writing the subclass PremiumVehicleBestDeals car-rentals also supplies premium cars, which are newer luxury cars. The charges forpremium cars are based on distance covered and duration of hire. The premium cars arecharged for each additional km beyond the free mileage allowed (based on daily mileage and theduration of hire). The free mileage allowance varies from one premium car to another. Assumethe charge per km after the daily free mileage is $0.10 per km. All premium cars must beserviced within a specified duration, which also varies from car to car.Derive a subclass of Vehicle named PremiumVehicle. This subclass should include threeadditional instance variables: free mileage allowance per day, service length (for example afterevery 10000 km) and the odometer reading at last service. The constructor for this class shouldtake three additional arguments corresponding to these three instance variables. This subclass(PremiumVehicle) must override the following methods which should make use of thesuperclass methods.serviceComplete(into do)// to update the odometer reading on completion of servicehireComplete(int odo)// to include mileage based charges in addition to duration based charges.hire(String hirer)// to verify whether car service is due for service (in addition to availability)// For example a premium car with last service 15,000, service length 10,000 and current// odometer reading 26,000 cannot be hired (even if it is available).print()// to display the instance variables mileage, last-service and service duration in addition to// the superclass instance variables (ID, description, …)public String toString()// Override the toString method to return the String representation of the objectProgramming Fundamentals Assignment 2 2019 Semester 221You are expected to test your PremiumVehicle class with the driver classTestPremiumVehicle class given below. Expected output is given below.// Class to test the PremiumVehicle class (provided)class TestPremiumVehicle{public static void main(String args[]){// passing ID, description, daily-rate, odometer reading, daily-mileage,// service-length, last-servicePremiumVehicle v = new PremiumVehicle("SAM134", "Lexus 05", 95.00,18000, 200, 10000, 17500);v.print();if ( v.hire("ST36784") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nCar " + v.getID() + " could not be hired ");v.print();DateTime.setAdvance(4,2,0);int odoReading = 28000;double val = v.hireComplete(odoReading);if ( val > 0.0 ){System.out.print("\nCar " + v.getID() + " is returned by " + v.getHirer());System.out.println(" Charges = " + val + " odo Reading = " + odoReading);}elseSystem.out.println("\nWARNING: Car " + v.getID()+ " could not be returned from hire ");v.print();Programming Fundamentals Assignment 2 2019 Semester 222DateTime.setAdvance(6,0,0);// attemption to hire a car which is due for serviceif ( v.hire("ST7656") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nCar " + v.getID() + " could not be hired ");DateTime.setAdvance(7,0,0);// sending car for serviceif ( v.service() == true)System.out.println("\nCar " + v.getID() + " is now sent to service");elseSystem.out.println("\nCar " + v.getID() + " could not be serviced ");v.print();DateTime.setAdvance(8,0,0);if ( v.serviceComplete(28100) == true)System.out.println("\nCar " + v.getID() + " is now returned from service");elseSystem.out.println("\nCar " + v.getID()+ " could not be returned from serviced ");v.print();DateTime.setAdvance(9,0,0);if ( v.hire("ST7656") == true)System.out.println("\nCar " + v.getID() + " is now hired to " + v.getHirer());elseSystem.out.println("\nCar " + v.getID() + " could not be hired ");v.print();}}Programming Fundamentals Assignment 2 2019 Semester 223Expected OutputC02QN0BFFVH6:PF19 charles$ java TestPremiumVehicle******************* Vehicle Details *********************Tue Sep 24 06:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=A Daily Rate=95.0 Odometer reading =18000Mileage Allowance = 200 Sevice Length = 10000 Last Service = 17500Car SAM134 is now hired to ST36784******************* Vehicle Details *********************Tue Sep 24 06:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=H Daily Rate=95.0 Odometer reading =18000Hirer=ST36784 Date/time of hire=Tue Sep 24 06:39:52 AEST 2019Mileage Allowance = 200 Sevice Length = 10000 Last Service = 17500Car SAM134 is returned by ST36784 Charges = 1375.0 odo Reading = 28000******************* Vehicle Details *********************Sat Sep 28 08:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=A Daily Rate=95.0 Odometer reading =28000Mileage Allowance = 200 Sevice Length = 10000 Last Service = 17500Car SAM134 could not be hiredCar SAM134 is now sent to service******************* Vehicle Details *********************Tue Oct 01 06:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=S Daily Rate=95.0 Odometer reading =28000Mileage Allowance = 200 Sevice Length = 10000 Last Service = 17500Car SAM134 is now returned from service******************* Vehicle Details *********************Wed Oct 02 06:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=A Daily Rate=95.0 Odometer reading =28100Mileage Allowance = 200 Sevice Length = 10000 Last Service = 28100Car SAM134 is now hired to ST7656******************* Vehicle Details *********************Thu Oct 03 06:39:52 AEST 2019vehicle ID=SAM134 Description=Lexus 05 Ststus=H Daily Rate=95.0 Odometer reading =28100Hirer=ST7656 Date/time of hire=Thu Oct 03 06:39:52 AEST 2019Mileage Allowance = 200 Sevice Length = 10000 Last Service = 28100Programming Fundamentals Assignment 2 2019 Semester 224Section II: Manipulating Vehicle and PremiumVehicle objects(i) Declare an array of 6 Vehicle references named vehs, that can refer up to 6 Vehicle orPremiumVehicle (subclass) objects. Create the Vehicle and PremiumVehicle objectsspecified below storing their references in vehs. Using a for loop and the print() methoddisplay the details of all objects (both Vehicle and PremiumVehicle) stored in vehs.(Polymorphism ensures correct version of print()is called)Object Type ID Description Dailyrateodometer Daily-MileageServicelengthLastserviceVehicle QJT123 Starlet 99 35.0 190000PremiumVehicle TUX132 BMW 05 90.0 12000 100 10000 5000Vehicle PTU121 Holden 03 60.0 165000Vehicle OCD856 Camry 04 65.0 230000PremiumVehicle TEY749 Jaguar 06 125.0 27000 120 12000 20000Vehicle TYR852 Subaru 02 60.0 270000(ii) Write a menu driven program to perform the common operations (see below)Vehicle MenuDisplay Available Cars 1Hire Vehicle 2Complete Hire 3Service Vehicle 4Complete Service 5Exit 6Your Choice : _For premium cars onlyProgramming Fundamentals Assignment 2 2019 Semester 225Specification/GuidelinesDisplay Option: Print the details of all vehicles. The details for all vehicles must include ID,description and odometer reading. If the vehicle is on hire, the hired data/time and hirer-namemust be displayed. The details for premium vehicles must in addition include service length, lastservice and mileage allowance per day.Hire Option: Prompt the user and read the vehicle ID. Locate the object searching through thearray of Vehicle references vehs. If no such vehicle exist, or it is not available for hire print anappropriate message and return to menu, otherwise, prompt user to enter ID of hirer andinvoke the hire() method.Complete Hire Option: Prompt the user and read the vehicle ID. Locate the object by searchingusing the array vehs. If no such vehicle exists or the vehicle is not on hire, print an appropriateerror message and return to menu. Otherwise prompt and read the current odometer readingand invoke the hireComplete() method to end the hire and to compute and display the charges.Complete Service option: Prompt the user and read the vehicle ID and locate the object. Ifoperation is not allowed, print error message otherwise prompt and read the current odometerreading and invoke the serviceComplete() method.Programming Fundamentals Assignment 2 2019 Semester 226Part C: (Covers All chapters)Vehicle Hire SystemOverviewYou are required to extend the program written in assignments 3 and 4, to manage all the commonoperations, taking into consideration discounts applicable to different types of customers.Customers are classified into two main categories, individual customers and corporate customerswith discounts computed differently. Hence you are required to write an abstract class namedCustomer with subclasses ICustomer and CCustomer.You are also required to enhance the Vehicle and PremiumVehicle class developed in theassignments 3 and 4. Exceptions must be thrown when an attempt is made to hire or complete ahire incorrectly (You can use the standard exception class or create your own exception class). Thefinal part requires you to write a class named ManageHiring that uses Customer (and its subclasses),and Vehicle (and it subclass) objects to facilitate the common operations. It also requires you to readand write Vehicle and Customer objects to text files, to allow persistence. (You are free to use arrayor any generic classes for storing the elements)Override toString() to return the String representation of the object in all your classesProgramming Fundamentals Assignment 2 2019 Semester 227Section I Enhancing Vehicle and PremiumVehicle classesIn this section you are required to modify the methods (hire(), completeHire() …) of Vehicle andsubclass to throw exceptions when invalid calls are made (see below). The exception thrownmust indicate the cause of error, allowing the caller to respond appropriately and recover ifpossible.public double hireComplete(… ) throws StatusException, Odo{…if (…) throw new StatusException();else { // process as normal…}}public void hire (… ) throws StatusException, OdometerException{}public void service(… ) throws StatusException{}public void serviceComplete(… )throws StatusException,OdometerException{}Programming Fundamentals Assignment 2 2019 Semester 228Section II Customer and subclassesCustomer classAll customers have a unique ID and name. All customers are offered discounts based on totalcharges though the method of computing discount differs for individual and corporatecustomers. In this part you are required to write the abstract class named Customer with:(i) Instance variables ID, name and phone(ii) Constructor taking as arguments the value for ID, name and phone(iii) An abstract method double getDiscount() to take as argument a double value for amount andto return a double (value for discount offered).(iv) Appropriate accessors for the instance variables.Subclass ICustomerMost individual customers are offered a discount based on previous mileage. Those with over100,000 mileage are offered 10% discount, and those with over 200,000 mileage are offered20% discount. (This past mileage must be updated after each hire) For example, if the customerhas 120,000km of mileage the discount offered for charge of $270 is $27. Individual customersare allowed only one car for hire at any one time. In this part you are required to write the classICustomer (extending Customer) with:(i) Instance variable for mileage(ii) Constructor taking as arguments values for ID, name, phone and mileage(iii) Implementation for the abstract method double getDiscount() declared in the superclassCustomer, which takes a double value (the total charge) and to returns a double (thediscount offered)Subclass CorporateCustomerAll corporate customers are offered a discount based on a preset rate that reflects therelationship with the corporation. Corporate customers are allowed to hire as many vehicles asrequired. For example, if the rate 0.08 (8%) then the discount offered on charge of $5000 is$400 ( 5000 * 0.08 ). In this part you are required to write the class CCustomer extendingCustomer with:(i) Instance variable for rate and an accessor for retrieving it.(ii) A mutator for changing the rate of discount when needed(iii) Constructor taking as arguments values for ID, name and the rate.(iv) Implementation for the abstract method double getDiscount() declared in the superclassCustomer, which takes a double value (the total charge) and to returns a double (thediscount offered)Programming Fundamentals Assignment 2 2019 Semester 229Section III Managing the Vehicle HiringIn this part you are required to write a class named ManageHiring following the steps outlinedbelow allowing Customer and Vehicle objects to be created, stored in arrays, manipulated,written and read back from files. All the Customer (and subclass objects) should be stored in afile named customers.txt and all the Vehicle (and subclass) objects should be stored in a filenamed vehicle.txt.Overall RequirementsThe users should be allowed to perform the following operations. You may write separatemethod for each of this activity. You are expected to write a menu-driven program. It shouldincorporate necessary input validation and exception handling allowing recovery wheneverpossible.1. Add a new vehicle (Vehicle or PremiumVehicle)- Input validation must ensure that ID is 6 characters and unique2. Add a new customer (either of type ICustomer or CCustomer)- Input validation must ensure ID is 6 characters, unique and starts with C3. Display details of available vehicles in the specified range (daily-rate)- Input validation must ensure lower limit of range is less than upper limit4. Hire a vehicle- must take into account constraints on individual customer- Any exceptions must be caught and reported5. Complete hire of vehicle- discount must be computed based on customer hiring the vehicle- Any exceptions must be caught and reported6. Send a vehicle for service / Return a vehicle from Service- Any exceptions must be caught and reported7. Writing all objects to files and restoring them, when program is restarted.8. Creating a report allowing rental income from each vehicle in the specified period to belisted.Please refer to the Canvas for detailed marking rubric