Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hello, please can you solve this java I need it quckly please since there's no much time to submit [20 pts] Implement the class Ticket
hello,
please can you solve this java
I need it quckly please since there's no much time to submit
- [20 pts] Implement the class Ticket characterized by one String data field ticketNumber, a static integer data field ticketsCounter, an array trips of Trip objects, and the integer tripNumber. The methods are:
- A constructor that increments ticketNumbers by one, create the trips array, and generates a ticket number by concatenating TN with the current ticketsCounter. The maxNbTrip parameter is used for the size of the array trips
- A method addTrip(t: Trip) that adds a trip to the set of trips of this ticket if it was possible.
- A method reduceCost() that calls the economize method on every trip that could be economized.
- A toString() method that returns a description about the ticket containing all its information and the information of its trips in the form:
The ticket TN312 has the following trips:
1. A flight departing from Beirut, going to Paris for a basic price of 650$. The seat class reserved for this flight is economic.
2. A train trip departing from Paris, going to Barcelona for a basic price of 270$. It is a VIP reservation.
Implement the driver class (application) as follows:
- Create a ticket object of maxNbTrip = 100 and add to it a first-class flight trip from Prague to Vienna for a basic price of 150$ and another bus trip from Vienna to Venice for a basic price of 92$.
- Write code to display total cost of the ticket, then reduce the cost of the ticket.
- Write code to display the total cost of the ticket, which includes the cost of all the tickets trips.
- Write code to display the number of bus trips in the ticket.
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