Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions: I. Each class must be in a .java file. 2. Write your name, ID, section and lab exam number at the beginning of your
Instructions: I. Each class must be in a .java file. 2. Write your name, ID, section and lab exam number at the beginning of your file. 3. Save your files. 4. Put your files into a folder named with your student ID (ex: 4300oooooo). 5. Compress your folder and submit it via the Blackboard and check if he/she received it. public class Date \{ private int day; private int month; private int year; public Date(int day, int month, int year) \{ this.day = day; this.month = month; this.year = year; Consider the above UML diagram and the previous given class Date: - Add a tostring method to this class, where its returned value may look like: Date =dd/mm/yyyy. Create a class called Reservation which contains the customer name, reservation date (reuse the Date class from Question 1), duration, and reservation number. Note that: - Refer to the UML diagram for the details of class members - reservationNo should be automatically computed (incremented by 1 for every new reservation) - The class has 2 constructors that initializes the instance variables, the default value for duration is 1 - It also has setDate, setDuration, and toString methods. The returned value of toString may look like: Reservation [ Name=?, Date=dd/mm/yyyy, Duration=?, Reservation Number = ? ] Question 2: To be answered in (15) Minutes / 1.5 Marks Create a class called PackageReservation that inherits from class Reservation (from Question 2). Note that: - Refer to the UML diagram for details of class members - The class has 2 constructors that initializes the instance variables - It also a toString method where its returned value may look like: Reservation [ Name=?, Date=dd/mm/yyyy, Duration=?, Reservation Number =?], Extras = ? Question 3: To be answered in (15) Minutes / 2.5 Marks Write a driver class called ReservationTest to test the classes created in the previous questions. At least, you have to: - declare/create 2 objects of type Reservation using different constructors - declare/create an object of type PackageReservation, then test setDuration using this object - Use method toString to print every object you have created
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