Programming 2 EXERCISE 3 – Java Basics: Flights-of-Fancy
PROGRAMMING 2 – SPRING 2023 EXERCISE 3 – JAVA BASICS
In this exercise, you will develop a program for an airline called Flights-of-Fancy. You will be developing a simple flight-booking system, which helps passengers book flight tickets.
THIS EXERCISE WILL BE GRADED (MAX: 10 points) SUBMISSION DEADLINE: MARCH 9, 2023, 23:00
Task 1. Install Maven
Follow the instructions available on the following page to install maven:
https://www.baeldung.com/install-maven-on-windows-linux-mac
As mentioned briefly in one of the lectures, maven is a build tool that helps you manage the different parts of your project and helps you meet the different library and package requirements necessary for successful execution of your program. One of that requirements is Java unit testing using JUnit.
Task 2. Accept the GitHub Classroom assignment
GitHub Classroom Link: https://classroom.github.com/a/DGkFbZg9
Go to the above link. It will take you to the following page, where you have to click
on “Accept this assignment”:
Then you will be taken to the following page:
PROGRAMMING 2 – SPRING 2023
If the above page does not change soon, simply refresh the page, and then you will
be shown the following page. Click on the GH link to your repository:
This is the repository that has the exercise 1 assignment. Clone this repository in
your local system following the same process as you did in your previous exercises.
Once cloned, start working on your exercise.
The only files you will work on are located in src -> main folder. Just follow the instructions given below and write a complete and correctly working program.
Task 3. Flight booking system for Flights-of-Fancy
Create a flight booking program that accepts the passenger’s details, the trip
requirements (absolute basics), and then finally display the details of the passenger, along
with the information about the trip. You DO NOT have to worry about implementing the
SOLID principles for this exercise. That will be evaluated in the future exercises.
The following requirements are MANDATORY:
• Your program must have these attributes stored in the variables listed below:
o flightCompany – This variable will store the constant Flights-of-Fancy. This
must NOT be entered by the Passenger.
o flightID – Every flight has an ID, e.g., FOF0345IN. This information is not
submitted by the passenger. It must be generated by the program
PROGRAMMING 2 – SPRING 2023
automatically after a booking is completed. This must NOT be entered by the Passenger. Consider using String concatenation to create value for this variable.
o passengerFullName – Passenger’s full name. DO NOT split it into first-name and last-name. The entire name should be stored in this one variable.
o tripSource–ThecityfromwherethePassengerwillstartthetrip.Fornow,this will be a constant value of NANJING. This must NOT be entered by the Passenger.
o sourceAirport – The airport from where the Passenger will take the departing flight. For now, this will be a constant value of NANJING LUKOU INTERNATIONAL AIRPORT. This must NOT be entered by the Passenger.
o tripDestination–ThedestinationcitywherethePassengerwillland.Fornow, this will be a constant value of OULU. This must NOT be entered by the Passenger.
o destinationAirport - The airport where the Passenger will land. For now, this will be a constant value of OULU AIRPORT. This must NOT be entered by the Passenger.
o departureDate – The date when the Passenger will start the trip. It should be in the format YYYY-MM-DD, for e.g., 2023-03-07. This variable cannot be a String. However, you can convert a String to date. You need to figure out how.
o returnDate – We are assuming that this will be a return trip. So, this variable will store the date when the Passenger returns from the trip. It should be in the format YYYY-MM-DD, for e.g., 2023-03-07. This variable cannot be a String. However, you can convert a String to date. You need to figure out how.
o childPassengers – No. of children the Passenger will be taking on the trip. Can accept ‘0’ as a value.
o adultPassengers – No. of adult passengers for the trip.
o totalPassengers – Total number of passengers for the trip. Simply an addition
of number of children passengers and adult passengers.
o departingTicketPrice – The price of the ticket for the departing journey. You
can come up with whatever logic you want. This must NOT be entered by the
Passenger.
o returnTicketPrice–Thepriceoftheticketforthereturnjourney.Youcancome
up with whatever logic you want. This must NOT be entered by the Passenger. o totalTicketPrice–Additionofthedepartingtrippriceandreturntripprice.This
must NOT be entered by the Passenger.
o ticketNumber – A number unique for every new trip. This must NOT be
entered by the Passenger. Consider using String concatenation to create a value for this variable.
Remember, the variable names should be exactly as stated above. If there’s any difference, like a spelling mistake, then the tests will fail, which means that you will lose points.
Therefore, DOUBLE CHECK your variable names. You can have more variables than what is listed above, if you want, and you can name it whatever you like. However,
PROGRAMMING 2 – SPRING 2023
the variable names we have listed above are MANDATORY and should be named
exactly the way they are.
IMPORTANT: None of the variables listed above should be directly accessible by an
outside class.
• You program MUST have the following behaviour implemented using appropriate methods:
o At least one Constructor that takes in as parameters EVERY INPUT that is accepted from the user.
o The necessary Getters and Setters. These should be named as the convention dictates. For instance, a Getter for ticketNumber MUST be called getTicketNumber(). Similarly, a Setter for the same variable MUST be called setTicketNumber().
• After accepting inputs from the Passenger and doing the necessary calculation, your program must display a confirmation message. It should be EXACTLY in the following format. Ignore the font colour. It’s only for highlighting purposes here.
Dear passengerFullName. Thank you for booking your flight with FLIGHT_COMPANY.
Following are the details of your booking and the trip:
Ticket Number: ticketNumber
From TRIP_SOURCE to TRIP_DESTINATION
Date of departure: departingDate
Date of return: returningDate
Total passengers: totalPassengers
Total ticket price in Euros: totalTicketPrice
In the above message, all the variables will display their relevant values that come from the inputs from the Passenger and your various calculation.
Be VERY CAREFUL in creating the above message. It should be EXACTLY how it is shown. Even a change in space between two words can fail the test.
Task 4. Commit and check the test results
Once you have finished writing your program and have confirmed that everything works exactly as instructed above, then you can commit your changes. The process is similar to how you have done in the previous exercises.
Remember to write “SUBMITTED” (without the quotes) as your commit message. This means that you have OFFICIALLY submitted your exercise assignment.
• Go to the current repository in GH, and click on “Actions”
PROGRAMMING 2 – SPRING 2023
Then you will see the following page. There, click on the topmost commit. In your case,
it should just read “SUBMITTED”. Depending on the testing results, it will either have
a green circle or a red one.
Then you will be taken to the following page. Click on “Autograding”
-
Then you will see the following page. Click on the third option that deals with autograding
PROGRAMMING 2 – SPRING 2023
• That list open up a very detailed description of the testing process. You need to scroll all the way down to the bottom, where you should something similar as the image below:
The first box will hold all the test results and their relevant description. The second box on the bottom will show the total points you received for the exercise. It will be out of a maximum of 10 points.