Question: Yummy Catering Create a class to hold event data for Yummy Catering. The class contains the following: Two public final static fields that hold the
Yummy Catering
Create a class to hold event data for Yummy Catering. The class contains the following:
Two public final static fields that hold the price per guest ($35) and the cutoff value for a large event (50 guests).
Three private fields that hold an event number, number of guests for the event, and the price. The event number is stored as a String because the company plans to assign event numbers such as M312.
Two public set methods that set the event number (setEventNumber()) and the number of guests (setGuests()). The price does not have a set method because the setGuests() method will calculate the price as the number of guests multiplied by the price per guest every time the number of guests is set.
Three public get methods that return the values in the three nonstatic fields.
A constructor that accepts an event number and number of guests as parameters. Pass these values to the setEventNumber() and setGuests() methods, respectively. The setGuests() method will automatically calculate the event price.
Another constructor that is a default constructor that passes A000 and 0 to the two-parameter constructor.
Save the file as Event.java.
Create an application that declares two event objects.
One event object uses the default constructor.
The other event object is constructed from values input by a user.
Display the details of each object by passing them, in turn, to a method named displayDetails(). Save the file as EventDemo.java. 2.a.
Sunshine Seashore Supplies
Sunshine Seashore Supplies rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists. Create a Rental class for the company. The Rental class contains the following:
Two public final static fields that hold the number of minutes in an hour (60) and the hourly rental rate ($40).
Four private fields that hold a contract number, number of hours for the rental, number of minutes over an hour, and the price. The contract number is stored as a String because the company plans to assign contract numbers such as K681.
Two public set methods. One sets the contract number (setContractNumber()). The other is named setHoursAndMinutes(), and it accepts the number of minutes for the rental and then sets the hours, extra minutes over an hour, and the total price. For example, 70 minutes is 1 hour and 10 minutes. The total price is $40 per hour plus $1 for every extra minute.
Four public get methods that return the values in the four nonstatic fields.
A constructor that accepts a contract number and number of minutes as parameters. Pass these values to the setContractNumber() and setHoursAndMinutes() methods, respectively. The setHoursAndMinutes() method will automatically calculate the hours, extra minutes, and price.
An overloaded default constructor that passes A000 and 0 to the two-parameter constructor. Save the file as Rental.java. 2.b. Create an application that declares two Rental objects. One Rental object uses the default constructor. The other Rental object is constructed from values input by a user. Display the details of each object by passing them, in turn, to a method named displayDetails().
Save the program as RentalDemo.java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
