Create an executable application in java, JAVA Programming

Assignment Help:

This assignment requires you to design, implement and test a program using Java features from the first half of the subject content. You are required to implement in Java all the classes presented in the conceptual model according the specifications provided. You are also required to develop a separate, console based user interface which, when combined with the problem domain classes, forms an executable application. Other than your own classes, your code may use only classes of the Java SE API described in this subject.

The model

The conceptual model below depicts a model for recording flight and passenger details associated with a travel agent.

Note that the model has significant shortcomings compared to a real system. For example, in a real system the name of every passenger occupying a seat would be recorded and there would be multiple flights per customer and multiple customers per flight. It has been significantly simplified to meet the requirements of this subject.

Structure

The TravelAgent class is the anchor point for the model and contains a collection of Customer objects and a collection of generalisedFlight objects. A specific flight can be either a BusinessFlight or an EconomyFlight. Each flight contains a collection of Movie objects.

Problem domain class specifications

Specifications are provided below for each individual class in the diagram. Students are expected to implement the classes correctly according to these specifications and with careful regard to the recommended coding styles and standards taught in the subject. Some of the programmatic techniques that require coding are left for individual choice. For example, extra attributes or methods may be added to any class as needed for sensible storage and functionality.

TravelAgent

This is the anchor class for the model and only one object will be expected to exist for the application. The object will have a name and will maintain and manage a collection of customers and a collection of flights.

Customer

Each Customer object is intended to hold seat information for a group of passengers and has an id attribute, which is a unique, read-only integer which is automatically generated when an object is created. The childSeats and adultSeats hold the number of seats booked and the name is a simple string. The numFlights attribute holds the total number of flights that this customer books over the life of the system and the cost attribute accumulates the total money paid or all these flights.

Flight

A Flight object is a generalised representation of a trip an aircraft takes. It contains a unique auto-generated flight number and other simple attributes holding the details of the flight. The baseprice holds the amount of money set by the airline for general travel. Note that this base price is never actually charged but is used instead as a basis for calculations done in the specialised subclasses BusinessFlight and EconomyFlight. There is more information about calculating flight costs in the description of these classes below.

The book function does not do any processing. It is an abstract method which simply provides every flight with the ability to accept customers and calculate costs. This method is implemented only in specialised subclasses.

BusinessFlight

A BusinessFlight is a specialisedFlight which accepts Customers via its book method and calculates the cost of the flight for that customer. For each adult seat required by the customer the method calculates a cost by multiplying the baseprice by the specific rate for the flight. For each child seat required the method calculates a cost by multiplying the flight's baseprice by the concession and by the specific rate set for the flight. These costs are added and returned to the method caller.

For example, suppose a business flight has a base price of $200, a concession of 50% and a rate of 3.1 (that is, a business flight is 3.1 times more expensive than a generic flight). If a customer with two adult and three children books this flight the cost will be calculated as follows.

rate * adults * baseprice = 3.1 * 2 * 200 (= 1240), plus
rate * children * concession * baseprice = 3.1 * 3 * 0.50 * 200 (= 930)

Total = 2170

As a side-effect, the book method updates the number of flights and the total cost attributes in the incoming Customer object.

EconomyFlight

An EconomyFlight is a specialisedFlight which accepts Customers via its book method and calculates the cost of the flight for that customer. Adult seats and child seats are charged at the same cost per seat, the baseprice. For economy flights there is however a discount to large groups. If the total number of seats is greater than four, each seat beyond the fourth attracts the discount.

For example, suppose an economy flight has a base price of $200, a concession of 50% (which is irrelevant for economy flights) and a groupDiscount of 20%. If a customer with two adult and three children books this flight the cost will be calculated as follows.

Total seats required = 5 (2 adults and 3 children)

First 4 seats at baseprice: 4 * 200 (=800), plus
Remaining seats attract 20% discount: 1 * 200 * 0.80 (=160)

Total = 960

As a side-effect, the book method updates the number of flights and the total cost attributes in the incoming Customer object.

Movie

A Movie is a simple object which holds the name of the movie and its length in minutes. Each flight has a collection of movies that may be shown during the journey.

User interaction and output

It is a specific requirement of this assignment that none of the problem domain classes listed above may contain any user interaction code, including the reading of values from a keyboard or interactive input device and none of the problem domain classes may generate any output for the user, such as screen messages or prompts.

User interface specifications

A Java application fulfilling the role of a user interface should be initiated in a class called TravelConsole. This class is not shown in the diagram (it is not a problem domain class) but is the controlling class for the whole application. The class should provide a console style user interface. That is, all output for the user should be directed to standard output (and appear on the screen) and all input should be obtained from standard input (read from the keyboard). Do not create a Graphical User Interface. You will be expected to do that in Assignment 2.

The TravelConsole class must contain the application's main method so that the application can be launched with a command equivalent to

javaTravelConsole

When the application is launched, it should create a single TravelAgent object and should install some sample BusinessFlight, EcomomyFlight, Customer and Movie objects (at least two of each). The application should implement at least the interactions listed below and show them on a menu.

Add an object

This option allows the user to create an object to represent a flight, customer or movie and add the object to the system. The user should choose which type of object to create, then should enter the details required, receiving appropriate prompts for all attributes. Use one menu option to allow access to all three types of objects, and use as much common code to deal with these three different types of object.

In the case of flight dates, user input should be as a string with a specified format. The application should convert the string input to a date. For example use SimpleDateFormat (in package java.text) to format a date to a string and to parse a string to a Date.

If the user chooses to add a flight, the user must choose between business and economy. If the user wishes to create a movie, a flight must be chosen to which the movie can be added. If there are no flights, the program must prompt the user to add one before returning to add the movie details.

List objects

Allow the user to choose the type of object to list then list the objects, displaying all their attributes and values. When listing flights indicate their type (e.g. business or economy).

Delete an object

Allow the user to choose which type of object to delete, before entering an id (for customer) or number (for flight) or name (for movie) to identify the object. After checking for a valid object, your program should display details of the object, and then ask the user to confirm this is the correct one before deleting. If the object chosen for deletion contains other objects, provide a summary, such as "This flight has 3 movies - do you still wish to delete it?"

Book a flight for a customer

Your program must provide an option to choose a customer and a flight, check for valid entries, and then invoke the book method of the flight, passing in the customer. Try to make this scenario work smoothly. For example, suppose a system has some customers and one is ready to book a flight. The application should first prompt and get an id from the user and locate the customer. It should then list the flights and allow the operator to choose the appropriate flight. Finally, when both the customer and the flight are located the booking should proceed. Display the total cost of each flight for each customer as it is booked.


Related Discussions:- Create an executable application in java

Describe inner classes in java, Describe Inner Classes in java? An inne...

Describe Inner Classes in java? An inner class is a class whose body is described inside another class, referred to as the top-level class. For instance: public class Queue {

Android App Clone, Hello, My friend Roshan from India told me that you pro...

Hello, My friend Roshan from India told me that you provide a high quality programming service which is why I''m here. I would like you to make a clone of an android app the app

Program, Write a program called Power that displays the positive powers of ...

Write a program called Power that displays the positive powers of 2. When the user enters the exponent at a prompt, the program displays 2 to that power. The program halts when the

What is asynchronous messaging, What is asynchronous messaging? Queue An...

What is asynchronous messaging? Queue Ans) Asynchronous messaging includes a client that does not wait for a message from the server. An event is used to trigger a message from

For in statement, It is a distinct type of loop, used to iterate through th...

It is a distinct type of loop, used to iterate through the properties of an object or the elements of an array. For instance assume the following statement that loops through th

Pogram must work on all realms and all ladders, Project Description: The...

Project Description: The program must work on all realms, all ladders, all cores (4x realms,2x ladders,2x cores) The program must be unpatchable and undetectable If patche

Describe j2ee?, J2EE (Java 2 Enterprise Edition) is an environment for depl...

J2EE (Java 2 Enterprise Edition) is an environment for deploying and developing enterprise applications on various operating system. The J2EE platform consists of J2EE components,

Want an expert with knowledge of uml diagrams, Want an expert with knowledg...

Want an expert with knowledge of UML diagrams and writing experience for pages writing including diagrams. This project needs 3-4 pages of technical writing about tickets reserv

Write a program on filling rectangles, Write a program on Filling Rectangle...

Write a program on Filling Rectangles ? The drawRect() method draws an open rectangle, a box if you prefer. If you need to draw a filled rectangle, use the fillRect() method. O

What are the components of struts, Struts components can be classify into M...

Struts components can be classify into Model, View and Controller: ? Model: Components like business logic /business processes and data are the type of model. ? View: HTML, J

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd