Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9525063

Have any Question?


Related Questions in Java

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As