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

Where the local varible declared, Where the local varible declared? Dec...

Where the local varible declared? Declaring variables within a function, makes them local .They are available only within that function and hold no meaning outside of it

Develop android geolocation service app, Project Description: Develop an...

Project Description: Develop an android service app that will run on the background. The app has to get the users location (longitude and latitude) every 5 minutes or when th

Waving two numbers into each other, I have to weave two positive integers t...

I have to weave two positive integers together. For example, if the numbers are 137 and 064, the output integer would be 103647. This has to be done using integer arithmetic (not s

Define when to use hashmap and when to use treemap, How do you decide when ...

How do you decide when to use HashMap and when to use TreeMap? When we want to perform deletion, insertion and locate elements in a Map then HashMap is used. Whereas TreeMa

Write a program that will analyze stocks, Write a program in java that will...

Write a program in java that will analyze stock data and purchase stock with the user''s specific risk and investment. User will select risk from a GUI, high, medium or low and inp

Mark sheet, Ask develop a project in visual basic for student mark-sheet p...

Ask develop a project in visual basic for student mark-sheet processing. #Minimum 100 words accepted#

What is initializing fields, What is Initializing Fields ? Fields can (...

What is Initializing Fields ? Fields can (and often should) be initialized while they're declared, just like local variables. class Car { String licensePlate = ""; // e.g

How the jms is different from rpc, In RPC the method invoker waits for the ...

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

Getting code, can i have code on this assignment: The code in the main meth...

can i have code on this assignment: The code in the main method should do the following: 1. Prompt the user for a string input value for the amount in dollars and store it in a va

What are the non-final functions in java object class?, The non-final funct...

The non-final functions are clone (), finalize (), toString (), equals () , hashCode () and. The other methods like wait (), getClass (), notifyAll (), notify () etc are final

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