Question
java2 Write the abstract class Seat. - Write the constructor. The price cannot be negative. - Write the method String toString(). Example for seat with
java2
Write the abstract class Seat. - Write the constructor. The price cannot be negative. - Write the method String toString(). Example for seat with a price of 600$ : seat, 600$ - Write the method boolean buy(double money)that enable buying a Seat. It will return true if the paid money is enough for buying the seat. - Implement the method compareTo of the interface Comparable. We compare two seats by comparing their price. 2. Write the class PremiumSeat that inhertis from Seat. - Write the constructor, - Override the method toString(). Example: for a premium seat with a price of 600$ and 400$ of fees : premium seat, D, 1000$
- Override the method boolean buy(double money)
3. Write the class NormalSeat that inhertis from Seat. - Write the constructor, - Override the method toString(). Example: for a normal seat with a price of 500$: normal seat, 23, 500$
4. Create the class Flight. - Write the constructor, - Write the method toString() which returns a String representing a Flight .
Flight : Beirut to Paris Seats: [normal seat, 23, 500$; premium seat, D, 1000$]
- Write the method boolean buySeat(Seat s, int sn, double money)that reserves the seat at position sn for the customer if it is not already reserved and if money is enough for buying the seat. A seat is not reserved if its corresponding cell is null. - Write the method total() that computes the total paid for all seats. 5. Write an application called Agency and create a Flight F from Beirut to Paris. a. In a loop allow the customers to buy any desired number of seats (normal or premium). b. Display all the information for this flight. c. Allow the user to pick any two seats and compare them.
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