IT 145 Project Three Guide
Use this step-by-step guide to complete all the methods needed for the software application’s
menu system.
TIP: As you work on your code, you can add sample data to test your code changes. Remember
that every time you exit the program, your sample data will be cleared. To avoid this issue, it is
recommended that you hard-code your sample data as illustrated in the beginning of the
Driver.java file. Some hardcoded data has already been created for you, but you may add more
if you would like. Look for these in-line comments at the start of the code:
// hardcoded ship data for testing
// Initialize ship list
Part One: Complete the printCruiseDetails() Method
1. Open the Cruise.java file. Pay attention to the variable names and the code for the
constructors, accessors, and mutators, which have already been created by your
development team. See below for where you will add code to finish the
printCruiseDetails() method.
// print cruise details
public void printCruiseDetails() {
// complete this method
}
2. Next, review the required functionality of the “Print Cruise Details” menu option below.
Menu Option Functionality
Print Cruise Details Prints a list, each cruise on a separate row
Data should be placed in columns that correspond to the variables:
cruise name, cruise ship name, departure port, destination, and return
port
3. Print Cruise Details Method: Write code for the printCruiseDetails() method. When your
code is complete, test the output by running the Driver.java class. Be sure the
completed method does the following:
a. Prints console output of all cruises and their details or, if there are no cruises in
the inventory, the output states this to the user
b. Prints the output in an easy-to-read format for the end users (for example, easy-
to-read output would present data in aligned columns)
TIP: Within the Ship.java file, there is a printShipData() method that is very similar to the
method you are tasked with creating. You can refer to that method as an example.
4. Industry Standard Best Practices: To ensure clarity, consistency, and efficiency among
all software developers, your code must do the following:
a. Follow appropriate naming conventions for variables and methods
b. Include descriptive in-line comments for all code you create and modify
Part Two: Complete the printShipList() Method
1. Open the Driver.java file. See below for where you will add code to finish the
printShipList() method.
} else if (listType == "active") {
System.out.println("\n\nSHIP LIST - Active");
// complete this code block
2. Next, review the required functionality of the “Print Ship List” menu option below.
Menu Option Validation Check(s) Functionality
Print Ship In Service
List
If no ships are in the inventory,
informs the user
Prints a list consisting of all s ...
IT 145 Project Three Guide Use this step-by-step guide.docx
1. IT 145 Project Three Guide
Use this step-by-step guide to complete all the methods needed
for the software application’s
menu system.
TIP: As you work on your code, you can add sample data to test
your code changes. Remember
that every time you exit the program, your sample data will be
cleared. To avoid this issue, it is
recommended that you hard-code your sample data as illustrated
in the beginning of the
Driver.java file. Some hardcoded data has already been created
for you, but you may add more
if you would like. Look for these in-line comments at the start
of the code:
// hardcoded ship data for testing
// Initialize ship list
Part One: Complete the printCruiseDetails() Method
2. 1. Open the Cruise.java file. Pay attention to the variable names
and the code for the
constructors, accessors, and mutators, which have already been
created by your
development team. See below for where you will add code to
finish the
printCruiseDetails() method.
// print cruise details
public void printCruiseDetails() {
// complete this method
}
2. Next, review the required functionality of the “Print Cruise
Details” menu option below.
Menu Option Functionality
ts a list, each cruise on a separate
row
variables:
3. cruise name, cruise ship name, departure port, destination, and
return
port
3. Print Cruise Details Method: Write code for the
printCruiseDetails() method. When your
code is complete, test the output by running the Driver.java
class. Be sure the
completed method does the following:
a. Prints console output of all cruises and their details or, if
there are no cruises in
the inventory, the output states this to the user
b. Prints the output in an easy-to-read format for the end users
(for example, easy-
to-read output would present data in aligned columns)
TIP: Within the Ship.java file, there is a printShipData() method
that is very similar to the
method you are tasked with creating. You can refer to that
method as an example.
4. 4. Industry Standard Best Practices: To ensure clarity,
consistency, and efficiency among
all software developers, your code must do the following:
a. Follow appropriate naming conventions for variables and
methods
b. Include descriptive in-line comments for all code you create
and modify
Part Two: Complete the printShipList() Method
1. Open the Driver.java file. See below for where you will add
code to finish the
printShipList() method.
} else if (listType == "active") {
System.out.println("nnSHIP LIST - Active");
// complete this code block
2. Next, review the required functionality of the “Print Ship
List” menu option below.
Menu Option Validation Check(s) Functionality
5. Print Ship In Service
List
If no ships are in the inventory,
informs the user
Prints a list consisting of all ship names that
are in service
3. Print Ship List Method: Complete the code for the
printShipList() method. When your
code is complete, test the output. Be sure that the completed
method provides console
output that returns ship details based on the String value passed
to the method.
TIP: The printShipList() method already supports printing ship
names and a full ship list.
You can review the code as you edit the printShipList() to
support printing ships in
service. See below for an example of the system’s printed
output for the full ship list.
Actual results do not need to match this example exactly. A text
version of this table is
6. also available.
4. Industry Standard Best Practices: To ensure clarity,
consistency, and efficiency among
all software developers, your code must do the following:
a. Follow appropriate naming conventions for variables and
methods
b. Include descriptive in-line comments for all code you create
and modify
Part Three: Complete the addShip() Method
1. In the Driver.java file, see below for where you will add code
to finish the addShip()
method.
// Add a New Ship
public static void addShip() {
// complete this method
}
7. https://learn.snhu.edu/d2l/lor/viewer/view.d2l?ou=6606&loIdent
Id=24106
2. Next, review the required functionality of the “Add Ship”
menu option below.
Menu Option Validation Check(s) Functionality
Add Ship - Ensures ship does not already exist in our system
- Ensures all class variables are populated
Adds ship to system
3. Add Ship Method: Write the code for the addShip() method.
When your code is
complete, test the output. Be sure that the completed method
does the following:
a. Adds a new Ship object
b. Includes all class variables
c. Updates appropriate ArrayList
TIP: You can refer to the Ship.java class constructor to make
sure you have included all
8. variables.
4. Industry Standard Best Practices: To ensure clarity,
consistency, and efficiency among
all software developers, your code must do the following:
a. Ensure that all user input is validated with appropriate
feedback to the user
b. Include exception handling
c. Follow appropriate naming conventions for variables and
methods
d. Include descriptive in-line comments for all code you create
and modify
Part Four: Complete the addCruise() Method
1. In the Driver.java file, see below for where you will add code
to finish the addCruise()
method.
// Adda New Cruise
public static void addCruise() {
9. // complete this method
}
2. Next, review the required functionality of the “Add Cruise”
menu option below.
Menu Option Validation Check(s) Functionality
Add Cruise - Ensures cruise does not already exist in
our system
- Ensures all class variables are populated
Adds cruise to system
3. Add Cruise Method: Write the code for the addCruise()
method. When your code is
complete, test the output. Be sure that the completed method
does the following:
a. Prompts the user for input
b. Requires all class variables when creating a cruise
c. Validates the ship name and ensures it is in service
d. Ensures ship name is not already assigned a cruise
10. e. Adds the new cruise to the cruiseList ArrayList if validation
checks pass
4. Industry Standard Best Practices: To ensure clarity,
consistency, and efficiency among
all software developers, your code must do the following:
a. Ensure that all user input is validated with appropriate
feedback to the user
b. Include exception handling
c. Follow appropriate naming conventions for variables and
methods
d. Include descriptive in-line comments for all code you create
and modify
Part Five: Complete the main() Method
1. At the beginning of the Driver.java file, see below for where
you will add code to finish
the main() method.
public static void main(String[] args) {
initializeShipList(); // initial ships
11. initializeCruiseList(); // initial cruises
initializePassengerList(); // initial passengers
// add loop and code here that accepts and validates user
input
// and takes the appropriate action. include appropriate
// user feedback and redisplay the menu as needed
2. Main Method: Complete the code for the main() method.
When your code is complete,
test the output. Be sure that the completed method does the
following:
a. Includes a loop that allows the user to interact with the menu
until they signal
that they want to exit the system
b. Maps user input to the specified functionality based on the all
menu options
listed below. A text version of this table is also available.
12. Note: The methods for Edit Ship, Edit Cruise, and Edit
Passenger do not need to be
completed but should still be mapped. When you test your
menu, if you enter 2, 4, or 6
for a menu selection, you should get a response that the “feature
is not yet
implemented.”
3. Industry Standard Best Practices: To ensure clarity,
consistency, and efficiency among
all software developers, your code must do the following:
a. Ensure that all user input is validated with appropriate
feedback to the user
b. Follow appropriate naming conventions for variables and
methods
c. Include descriptive in-line comments for all code you create
and modify
Part Six: Submission
Upon completing your code for each class file, review the What
to Submit section of the Project
Three overview and submit all files to the Project Three
submission.
13. https://learn.snhu.edu/d2l/lor/viewer/view.d2l?ou=6606&loIdent
Id=24108
System Specification Document
Overview
Our mission at Luxury Ocean Cruise Outings is to provide the
accurate and efficient ability to coordinate cruise bookings for
our growing list of affiliate luxury cruise ship owners and
cruise lines. We desire a simple menu-based system to perform
core functions that are essential to our daily operations.
The envisioned system will include three primary components:
ships, cruises, and passengers. The Luxury Ocean Cruise
Outings company does not own ships; instead, it creates cruises
using available ships. Once a ship is placed “in service,” it is
available for cruises. Passengers can be added to cruises. Here
are the relationships of these components:
· Ships have unique names.
· Cruises have unique names and are assigned to ships.
· Ships can have multiple cruises.
· Each ship has a finite number of passenger cabins (Balcony,
Ocean View, Suite, and Interior). Overbooking is not permitted.
· Passengers are assigned to cruises.System Menu
We require a simple text-based menu system that should
resemble the illustration below. A text version of this table is
also available. Comment by Gutschow, Molly: Jordan: Link to
IT 145 System Menu Text Version.
CruiseShipProject/.classpath
17. public String toString();
}
CruiseShipProject/bin/Ship.classpublicsynchronizedclass Ship {
private String shipName;
private int roomBalcony;
private int roomOceanView;
private int roomSuite;
private int roomInterior;
private boolean inService;
void Ship();
void Ship(String, int, int, int, int, boolean);
public String getShipName();
public int getRoomBalcony();
public int getRoomOceanView();
public int getRoomSuite();
public int getRoomInterior();
public boolean getInService();
public void setShipName(String);
public void setRoomBalcony(int);
public void setRoomOceanView(int);
public void setRoomSuite(int);
public void setRoomInterior(int);
public void setInService(boolean);
public void printShipData();
public String toString();
}
CruiseShipProject/src/Cruise.javaCruiseShipProject/src/Cruise.j
avapublicclassCruise{
// Class Variables
privateString cruiseName;
privateString cruiseShipName;
20. }
CruiseShipProject/src/Driver.javaCruiseShipProject/src/Driver.j
avaimport java.util.ArrayList;
import java.util.Scanner;
importstatic java.lang.Integer.parseInt;
publicclassDriver{
// class variables (add more as needed)
privatestaticArrayList<Ship> shipList =newArrayList();
privatestaticArrayList<Cruise> cruiseList =newArrayList();
privatestaticArrayList<Passenger> passengerList =newArrayList
();
publicstaticvoid main(String[] args){
initializeShipList();// initial ships
initializeCruiseList();// initial cruises
initializePassengerList();// initial passengers
// add loop and code here that accepts and validates user input
// and takes the appropriate action. include appropriate
// user feedback and redisplay the menu as needed
}
// hardcoded ship data for testing
// Initialize ship list
publicstaticvoid initializeShipList(){
add("Candy Cane",20,40,10,60,true);
add("Peppermint Stick",10,20,5,40,true);
21. add("Bon Bon",12,18,2,24,false);
add("Candy Corn",12,18,2,24,false);
}
// hardcoded cruise data for testing
// Initialize cruise list
publicstaticvoid initializeCruiseList(){
Cruise newCruise =newCruise("Southern Swirl","Candy Cane","
Miami","Cuba","Miami");
cruiseList.add(newCruise);
}
// hardcoded cruise data for testing
// Initialize passenger list
publicstaticvoid initializePassengerList(){
Passenger newPassenger1 =newPassenger("Neo Anderson","Sou
thern Swirl","STE");
passengerList.add(newPassenger1);
Passenger newPassenger2 =newPassenger("Trinity","Southern S
wirl","STE");
passengerList.add(newPassenger2);
Passenger newPassenger3 =newPassenger("Morpheus","Souther
n Swirl","BAL");
passengerList.add(newPassenger3);
}
// custom method to add ships to the shipList ArrayList
publicstaticvoid add(String tName,int tBalcony,int tOceanView,
int tSuite,int tInterior,boolean tInService){
Ship newShip =newShip(tName, tBalcony, tOceanView, tSuite,
tInterior, tInService);
shipList.add(newShip);
}
22. publicstaticvoid printShipList(String listType){
// printShipList() method prints list of ships from the
// shipList ArrayList. There are three different outputs
// based on the listType String parameter:
// name - prints a list of ship names only
// active - prints a list of ship names that are "in service"
// full - prints tabbed data on all ships
if(shipList.size()<1){
System.out.println("nThere are no ships to print.");
return;
}
if(listType =="name"){
System.out.println("nnSHIP LIST - Name");
for(int i =0; i < shipList.size(); i++){
System.out.println(shipList.get(i));
}
}elseif(listType =="active"){
System.out.println("nnSHIP LIST - Active");
// complete this code block
}elseif(listType =="full"){
System.out.println("nnSHIP LIST - Full");
System.out.println("-----------------------------------------------");
System.out.println(" Number of Rooms In");
System.out.print("SHIP NAME Bal OV Ste Int Servic
e");
System.out.println("n-----------------------------------------------
");
for(Ship eachShip: shipList)
eachShip.printShipData();
}else
23. System.out.println("nnError: List type not defined.");
}
publicstaticvoid printCruiseList(String listType){
if(cruiseList.size()<1){
System.out.println("nThere are no cruises to print.");
return;
}
if(listType =="list"){
System.out.println("nnCRUISE LIST");
for(int i=0; i < cruiseList.size(); i++){
System.out.println(cruiseList.get(i));
}
}elseif(listType =="details"){
System.out.println("nnCRUISE LIST - Details");
System.out.println("---------------------------------------------------
---------------------------------------");
System.out.println(" |--------------------
--PORTS-----------------------|");
System.out.print("CRUISE NAME SHIP NAME DE
PARTURE DESTINATION RETURN");
System.out.println("n-------------------------------------------------
----------------------------------------");
for(Cruise eachCruise: cruiseList)
eachCruise.printCruiseDetails();
}else
System.out.println("nnError: List type not defined.");
}
publicstaticvoid printPassengerList(){
if(passengerList.size()<1){
System.out.println("nThere are no passengers to print.");
return;
}
System.out.println("nnPASSENGER LIST");
System.out.println("---------------------------------------------------
24. --");
System.out.print("PASSENGER NAME CRUISE R
OOM TYPE");
System.out.println("n-------------------------------------------------
----");
for(Passenger eachPassenger: passengerList)
eachPassenger.printPassenger();
}
// display text-based menu
publicstaticvoid displayMenu(){
System.out.println("nn");
System.out.println("tttLuxury Ocean Cruise Outings");
System.out.println("tttttSystem Menun");
System.out.println("[1] Add Ship [A] Print Ship Names"
);
System.out.println("[2] Edit Ship [B] Print Ship In Servic
e List");
System.out.println("[3] Add Cruise [C] Print Ship Full Li
st");
System.out.println("[4] Edit Cruise [D] Print Cruise List")
;
System.out.println("[5] Add Passenger [E] Print Cruise Deta
ils");
System.out.println("[6] Edit Passenger [F] Print Passenger L
ist");
System.out.println("[x] Exit System");
System.out.println("nEnter a menu selection: ");
}
// Add a New Ship
publicstaticvoid addShip(){
// complete this method
25. }
// Edit an existing ship
publicstaticvoid editShip(){
// This method does not need to be completed
System.out.println("The "Edit Ship" feature is not yet impleme
nted.");
}
// Add a New Cruise
publicstaticvoid addCruise(){
// complete this method
}
// Edit an existing cruise
publicstaticvoid editCruise(){
// This method does not need to be completed
System.out.println("The "Edit Cruise" feature is not yet imple
mented.");
}
// Add a New Passenger
publicstaticvoid addPassenger(){
Scanner newPassengerInput =newScanner(System.in);
System.out.println("Enter the new passenger's name: ");
String newPassengerName = newPassengerInput.nextLine();
// ensure new passenger name does not already exist
26. for(Passenger eachPassenger: passengerList){
if(eachPassenger.getPassengerName().equalsIgnoreCase(newPas
sengerName)){
System.out.println("That passenger is already in the system. Exi
ting to menu...");
return;// quits addPassenger() method processing
}
}
// get cruise name for passenger
System.out.println("Enter cruise name: ");
String newCruiseName = newPassengerInput.nextLine();
// ensure cruise exists
for(Cruise eachCruise: cruiseList){
if(eachCruise.getCruiseName().equalsIgnoreCase(newCruiseNa
me)){
// cruise does exist
}else{
System.out.println("That cruise does not exist in the system. Ex
iting to menu...");
return;// quits addPassenger() method processing
}
}
// get room type
System.out.println("Enter Room Type (BAL, OV, STE, or INT:
");
String room = newPassengerInput.nextLine();
// validate room type
if((room.equalsIgnoreCase("BAL"))||(room.equalsIgnoreCase("
OV"))||
(room.equalsIgnoreCase("STE"))||(room.equalsIgnoreCase("INT
"))){
// validation passed - add passenger
Passenger newPassenger =newPassenger(newPassengerName, ne
27. wCruiseName, room.toUpperCase());
passengerList.add(newPassenger);
}else{
System.out.println("Invalid input. Exiting to menu...");
return;// quits addPassenger() method processing
}
}
// Edit an existing passenger
publicstaticvoid editPassenger(){
// This method does not need to be completed
System.out.println("The "Edit Passenger" feature is not yet im
plemented.");
}
// Method to check if input is a number
publicstaticboolean isANumber(String str){
for(int i =0; i < str.length(); i++){
if(Character.isDigit(str.charAt(i))==false)
returnfalse;
}
returntrue;
}
}
CruiseShipProject/src/Passenger.javaCruiseShipProject/src/Pass
enger.javapublicclassPassenger{
// Class variables
privateString passengerName;
privateString passengerCruise;
privateString passengerRoomType;
32. // print method
publicvoid printShipData(){
int spaceCount;
String spaces ="";
spaceCount =20- shipName.length();
for(int i =1; i <= spaceCount; i++){
spaces = spaces +" ";
}
System.out.println(shipName + spaces + roomBalcony +"t"+
roomOceanView +"t"+ roomSuite +"t"+
roomInterior +"tt"+ inService);
}
// method added to print ship's name vice memory address
@Override
publicString toString(){
return shipName;
}
}
Project Three Guidelines and Rubric
Competency
In this project, you will demonstrate your mastery of the
following competency:
33. • Write programs using object-oriented conventions in
accordance with
industry standard best practices
Scenario
You work for Global Rain, a software
engineering company that specializes in
custom software design and development. As a
junior software developer, you are part of a
software development team at Global Rain that
collaborates to create software solutions for
entrepreneurs, businesses and government
agencies around the world.
Your Global Rain software development team
has been asked to develop a menu-driven
system for the Luxury Ocean Cruise Outings company. This
company
coordinates cruise bookings for luxury ship owners and cruise
lines. As a
returning customer for Global Rain, Luxury Ocean Cruise
Outings has
34. requested a simple menu-based system to perform core
functions that are
IT-145-T1604 Found in App Develo… RL
Reflect in ePortfolio Download Print
Open with docReader
Activity Details
You have viewed this topic
Last Visited Oct 10, 2019 8:21 PM