Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

  1. [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:

  1. 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
  2. A method addTrip(t: Trip) that adds a trip to the set of trips of this ticket if it was possible.
  3. A method reduceCost() that calls the economize method on every trip that could be economized.
  4. 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:

  1. 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$.
  2. Write code to display total cost of the ticket, then reduce the cost of the ticket.
  3. Write code to display the total cost of the ticket, which includes the cost of all the tickets trips.
  4. Write code to display the number of bus trips in the ticket.
Implement the below classes and interface as presented in the following UML diagram except the class BusTrip for which you will find the code provided below. For all classes implement only the getters that you will need later in your code. "Interface" Economical + economize(): void Ticket - ticket Number: String - ticketsCounter: int trips: Trip) - tripNumber: int + Ticket(maxNbTrip: int) + addTriplt: Trip): void + seduce Costo: void + toString(): String A Trip - departureCity: String - arrivalCity: String - basicPrice: double + Irin.de: String, ac: String, br: double) + salsulateCesto: double + toString(): String BusTrip + Bus Trin(de: String, ac: String, br: double) + toString(): String Flight - seatClass: String + Flights: String, ac: String, bp: double, seatClass: String) + toString(): String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago