Question: Programming Task (100 marks) Given the UML diagram below implement the code in NetBeans. Ticket -id:int -price: int -startTime:int -endTime:int -departure:String -destination: String -nrOfStops:int
Programming Task (100 marks) Given the UML diagram below implement the code in NetBeans. Ticket -id:int -price: int -startTime:int -endTime:int -departure:String -destination: String -nrOfStops:int -availableQuantity:int +Ticket() +Ticket(id:int, price:int,startTime:int, endTime:int,dep:String, dest:String, nrOfStops:int, availableQuantity:int) Train Ticket +toString(): String +calc():int -cabinNr:int -soldTickets:int +TrainTicket() +TrainTicket(id:int, price:int,startTime:int, endTime:int,dep:String, dest:String, nrOfStops:int, availableQuantity:int, cabin Nr:int,soldTickets:int) +toString():String +calc(): int -Method calc() is abstract. 4 Plane Ticket -nrOfLuggage:int -changeTicket: boolean Create abstract class Ticket, and classes TrainTicket and Plane Ticket. Define all attributes and implement all necessary getters and setters for Ticket, TrainTicket and Plane Ticket. Implement the methods in class Ticket with the following specifications: +Plane Ticket() +Plane Ticket(id:int, price:int,startTime:int, endTime:int,dep:String, dest:String, nrOfStops:int, availableQuantity:int, nrOfLuggage:int, waitingTime: int) +toString():String +add LuggageToPrice(): int +calc():int -Method toString() will return a string with all the information about the ticket, as in the example below: "Ticket 1558 from Egaila to Salmiya leaves at 9, arrives at 10, stops 5 times costs 1 KD. In total available tickets 120." Implement the methods in class TrainTicket with the following specifications: -Method calc() will calculate and return the profit made from the sold tickets. (profit = price* soldTickets) -Method toString() will return a string with all the information about the TrainTicket as in the example below: "Ticket 1234 from Egaila to Salmiya leaves at 9, arrives at 10, stops 5 times costs 1 KD. In total available tickets 120 for 60 cabins, and 23 tickets are sold." if any ticket has been sold, or "Ticket 1234 from Egaila to Salmiya leaves at 9, arrives at 10, stops 5 times costs 1 KD. All tickets for 60 cabins are still available" if no ticket has been sold yet. Implement the methods in class Plane Ticket with the following specifications: -Method toString() will return a string with all the information about the Plane Ticket as in the example below: "Ticket 1234 from Kuwait to Rome leaves at 9, arrives at 18, stops 2 times costs 150 KD; in total 3Pieces of luggage are booked." -Method calc() will calculate and return the final price of the plane ticket. If the value of the textfield changeTicket is no, then the final price is the sum of the ticket price and the number of luggage multiplied by 15, if the value of changeTicket is yes, then the final price is the sum of the ticket price+20, and the number of luggage multiplied by 15. Write as a comment in the beginning of your code, your section, and your name &ids. Submit your project in zip or rar format in moodle, your section's page. 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
