[SOLVED] CS262 Project 3: Cruise Ship Manifest

30 $

CS262 Project 3: Cruise Ship Manifest
Due 11:59 P.M., April 25, 2015

Modifications and Errata:
April 2, 2015: Initial posting
April 6, 2015: Corrected copy snafu in section 4.G of implementation steps

April 7, 2015: Modified 4.E in implementation steps to allow parameters. Remove reference to Global variable in 4.C

Introduction:
Gilligan’s Cruise Company (GCC) is planning to modernize their ship, the SS Minnow, with the latest technology. One aspect of their upgrades is how they keep track of passenger shipboard accounts and whether they are on or off the ship.

In the past, they kept track of customer embarking and disembarking by having a security person look at the passenger ID and letting them on or off the ship. With their new upgrade, they will have a computer program keep track of each passenger’s location (whether they are on or off the ship), as well as each passenger’s ship accounts (bar bills, gift shop purchases, island tours, etc.). Passengers will carry a cruise card that they will use when embarking, disembarking and making a purchase. All cruise itineraries will include a stop at Gilligan’s Island, the cruise line’s private island, for a three hour tour. While on the island, and at other ports of call, passengers may also use their shipboard accounts to buy coconuts and other souvenirs.

Your company has been selected by GCC to write this computer program, and you have been selected by your boss to design and code it. GCC has given the following specifications for their new system:

  1. Information for each passenger will be kept in a single data type (struct) and will consist of:
    • A unique passenger ID (integer)
    • Passenger First Name (char string of 25 characters)
    • Passenger Last Name (char string of 35 characters)
    • Current balance of passenger shipboard account (double)
    • Passenger Location (char)
      • If passenger is on-board, the value of this data will be 1
      • If the passenger is visiting the current island, the value of this data will be 0
  1. The passenger data will be read from an ASCII file at the start of the program. The data will consist of the unique ID, and the passenger’s first and last name. Each line in the file will contain a single data item. When the data is read, the balance of the passenger’s account will be set to 0.00, and the passenger will be considered to be off the ship (Location value is 0).
  2. Passengers will be identified by their unique ID. Thus when a passenger embarks, disembarks or makes an on-board purchase, their ID card is scanned, and the unique id is read from the magnetic strip on their cruise card. This ID will be used to search for the customer information so that it can be updated.
  3. As passengers arrive on the ship, the passenger location value will be set to 1. If the passenger location value indicates that they are already on the ship, a message will be printed stating that the passenger must have slipped off the ship without going through security.
  4. Similar to #3, when a passenger leaves the ship, the location value will be set to 0. If the location value indicates that they are currently off the ship, a message will be printed stating that the passenger must have gotten on the ship without going through security.
  5. When a passenger makes an on-board purchase, the amount of the purchase will be added to their shipboard account. If the location value of the passenger indicates they are currently off the ship, a message will be printed stating that the passenger location is incorrect. The location value will be set to 1 and the amount of the purchase will be added to their shipboard account.
  6. Similar to #6, when a passenger makes an off-board purchase, the amount of the purchase will be added to their shipboard account. If the location value of the passenger indicates they are currently on the ship, a message will be printed stating that the passenger location is incorrect. The location value will be set to 0 and the amount of the purchase will be added to their shipboard account.
  7. The program must have the ability to print:
    • Information for a single passenger (identified by the unique ID)
    • Passenger information for all passengers currently on board
    • Passenger information for all passengers currently on shore
    • When printing passenger information, the passenger’s Unique ID, First and Last name, and current shipboard account balance is printed
  8. At the end of the cruise, all passengers will exit the ship. The program will then calculate the total amount of money the passengers spent on the cruise, compute the average amount of money spent per passenger, and print this information.

Implementation:
The specifications for this project have a great deal of detail. However, the fact that they are detailed can be used to your advantage, in that you can break the project into smaller units and work on them separately to create the complete project.

  1. You will implement this program using singly Linked Lists. You will create a linked list node struct that will contain a passenger struct, and a pointer to a linked list node.
  2. You will have, at a minumum, two linked lists. One for passengers on board the ship (onShip), and one for passengers that are not on the ship (offShip).
  3. The nodes in the linked lists will always be ordered by Passenger ID.
  4. Your program will be menu driven. The program will contain a main menu, and several choices from this menu will bring up a sub-menu. See the Menu Specifications below.
  5. A sample script and output will be provided that you may test with your program. Your program must respond to inputs in the same manner that the sample script responds. In other words, your program should not add unnecessary prompts for user input, nor should it skip prompts for input (or prompt for multiple data items with a single prompt).
  6. Two input files containing Names and Passenger IDs are provided, one for testing, and one for a more realistic number of passengers.

Menu Specifications:

  • Main Menu : The main menu will contain the following choices and functionality:
  1. Read Passenger Mainfest
    1. Prompt the user for a filename containing the “Passenger Manifest.”
    2. Open this file and read the information from the file, creating Passengers and adding them to the offShip list
    3. If the file cannot be found, print a message stating this fact, and return to the Main Menu.
  2. Embark all passengers
    1. Move all passengers from the offShip list to the onShip list
  3. Passenger Information
    1. Display the Passenger Information Menu (See below)
  4. Print Menu
    1. Display the Print Menu (See below)
  5. Debark all passengers
    1. Move all passengers from the onShip list to the offShip list
  6. Quit
    1. Remove all nodes from both the onShip and offShip lists and free the memory.
    2. Exit the program
  • Passenger Information Menu:
  1. Embark Passenger
    1. The program prompts for the passenger ID. The passenger node is removed from the offShip list and added in the proper position to the the onShip list. The passenger location is set to be on board.
    2. If the passenger ID is not found in the offShip list, the onShip list is searched. If the passenger is found in the onShip list, a message stating so is written to the console, and the program returns to the main menu.
    3. If the passenger is not found in either list, a message stating an incorrect ID was entered is written to the console, and the program returns to the Passenger Information menu.
  2. Debark Passenger
    1. The program prompts for the passenger ID. The passenger node is removed from the onShip list and added in the proper position to the the offShip list. The passenger location is set to be of the ship.
    2. If the passenger ID is not found in the onShip list, the offShip list is searched. If the passenger is found in the offShip list, a message stating so is written to the console, and the program returns to the main menu.
    3. If the passenger is not found in either list, a message stating an incorrect ID was entered is written to the console, and the program returns to the Passenger Information menu.
  3. Passenger OnBoard Purchase
    1. The program prompts for the passenger ID. The program then prompts for the amount of purchase as a floating point value.
    2. The program searches for the passenger node, first in the onShip list, then (if it is not found in the onShip list) the offShip list is searched.
    3. Once the node is found, the purchase amount is added to the current balance of the shipboard account for that passenger. Also, the Passenger location is set to 1 if it is not already (if the passenger was in the offShip list).
    4. If the passenger ID is not found, a message stating an incorrect ID was entered is written to the console, and the program returns to the Passenger Information menu.
  4. Passenger OffBoard Purchase
    1. The program prompts for the passenger ID. The program then prompts for the amount of purchase as a floating point value.
    2. The program searches for the passenger node, first in the offShip list, then (if it is not found in the offShip list) the onShip list is searched.
    3. Once the node is found, the purchase amount is added to the current balance of the shipboard account for that passenger. Also, the Passenger location is set to 0 if it is not already (if the passenger was in the onShip list).
    4. If the passenger ID is not found, a message stating an incorrect ID was entered is written to the console, and the program returns to thePassenger Information menu.
  5. Synchronize Passenger Lists
    1. The program traverse through the two passenger lists. Any passenger in the onShip list with the location set to 0 will be removed from the onShip list and moved to the offShip list. Any passenger in the offShip list with the location set to 1 will be removed from the offShip list and moved to the onShip list.
  6. Return to Main Menu
  • Print Menu:
  1. Print Account for Single Passenger
    1. Prompt the user for the Passenger ID.
    2. Search both onShip and offShip lists until the passenger is found
    3. Print the information for that passenger.
    4. If the Passenger ID is not found, write a message to the console stating that fact and return to the Print Menu.
  2. Print All Passenger Accounts
  3. Print Accounts for onShip Passengers
  4. Print Accounts for offShip Passengers
  5. Return to Main Menu

Additional Specifications:

  • Your program will have at least two source files
    • Source file 1 will be named Project3_main_<username>_<lab_section>.c
      • This file will contain your main() function as well as the functions to handle the menus
    • Source file #2 will be named Project3_llist_<username>_<lab_section>.c
      • This file will contain your linked list functions and other functions necessary to complete the project.
  • You will provide a Makefile that will compile your source files into object files, and link them into a single executable
  • You may not use global variables for the linked lists. You must pass the heads of your lists as parameters to the functions.
  • You may implement your linked lists using either a dummy node or using a pointer to the head of the list.
  • It is suggested that you create separate generic linked list functions that perform insertions, deletions, searches, etc. These functions are then used by specific functions(Passenger_Onboard_Purchase() for example) to retrieve references to the desired nodes where they will be modified.

Submission Instructions:
You will submit a tar file containing your source code files, your Passenger Manifest file, and Makefile. To do this, perform the following steps:

  1. On zeus, make a directory to hold your files for submission. This directory must be named “Project3_<username>_<lab_section>”
  2. Copy or move your source file, manifest file, and Makefile to this directory.
  3. Perform the following command to create your tar file:

                tar -cvf Project3_<username>_<lab_section>.tar  Project3_<username>_<lab_section>

Submit this tar file to Blackboard for the Project 3 assignment.

Suggested Implementation Steps:

Below is a step by step guide you can use to create your program for this project. You do not have to follow this procedure, but you will likely have greater success in completing your project on time if you do so. Breaking the creation of the program into smaller portions will make your code easier to maintain and debug.

  1. Create separate void functions with no parameters to print each menu (one for the Main Menu, one for the Passenger Information Menu, one for the Print Menu, etc.). Use these functions only to print the menus (do not prompt for a menu choice in these functions).
  2. Create the logic to use the menus.
    1. In the main() function, create a loop to print the Main Menu (by calling its print function) and prompt for user input.
    2. Use switch statements based on user input to call other functions (don’t put other functionality in the switch statements – just call other functions).Also break out of the loop if the user chooses to end the program.
    3. Create the other functions based on user input.
      1. If the function is to print a submenu, add functionality print the submenu, prompt the user for input, then add a switch statement to call “stub functions” based on user input.
      2. If the other functions are not submenu functions, create a “stub function.” A stub function has no parameters or functionality other than to print an informational message, such as “In Function PassengerPurchase.” You will add parameters and functionality to it later.
    4. Test the logic of your menus by checking each combination of input from the Main Menu through the submenus and stub functions to ensure that each stub function is reached correctly.
    5. Once you have the menus working, add the linked list functions.
      1. Create the struct for the Passenger Information
      2. Create a Linked List struct. This struct will contain a Passenger Information struct and a reference (usually called Next) to a Linked List struct.
      3. Create two linked list head nodes in your main() function, one for the onShip list and one for the offShip list.
      4. Add parameters to your functions (where needed) to pass the linked list head nodes to the stub functions.
      5. Write a function that creates a Linked List node. This function will likely have a file descriptor as a parameter. It will use memory allocation to create a Linked List node, prompt for all information required for a passenger struct (reading it in from the file referenced by the file descriptor), initialize the Passenger struct portion of the Linked List node with this information,set the Next pointer to NULL, and return a pointer to this newly created node.
      6. Create a function that takes a pointer to a Linked List node as a parameter and returns the Passenger ID.
      7. Create a Linked List function that will return a pointer to a node in a linked list, without removing that node. This function takes the head of a linked list and an integer value (the Passenger ID) as parameters. If the node containing the Passenger ID is not found in the linked list, a void pointer is returned.
      8. Create a Linked List function that will add a node to a linked list. This function takes the head of a linked list and a pointer to the node to add as parameters. The function will use the function created in Step F to determine where the node will be added.
      9. Create a Linked List function that will remove a node from a linked list, and return a pointer to the removed node. This function takes the head of a linked list and an integer value (the Passenger ID) as parameters. If the node containing the Passenger ID is not found in the linked list, a void pointer is returned.
    6. The Linked List functions created in the previous step are difficult to test on their own. You will test them by gradually adding functionality to your program.
      1. Implement the Main Menu function to Embark all Passengers
      2. Implement the Print Menu function to Print onShip Passengers
        1. Create a function that takes the head of a Linked List as a parameter and prints the information contained all nodes of that list
        2. Call this function with the onShip list as the parameter.
      3. Test these two functions to see if the program can add all the passengers to the onShip list and then print them.
      4. Implement the Main Menu function to Debark all Passengers
      5. Implement the Print Menu function to Print offShip Passengers.
        1. Note that this is the same function created for #2 above. It just takes the offShip list as a parameter.
      6. Test the Debark and Print offShip Passengers functions.
      7. Implement and test the Print All Passengers function
        1. This is trivial – just call the Print onShip Passengers and the Print offShip Passengers functions.
      8. Implement and test the Print Single Passenger function
        1. You will use the function created in step 5.9 above
      9. Now implement and test the functions for the Passenger Information Menu
        1. There is not much advantage to the order that these functions are implemented, although the Synchronize Passenger Lists functions might be best to implement after the Purchase functions are implemented.
      10. Test your code thoroughly

A suggested timeframe to complete the steps is as follows:
Week 1:Items 1-3. Start on Item 4
Week 2:Items 4-5 (possibly Item 6 also)
Week 3:(First half):  Item 6 (if not already completed). Start Item 7
Week 3:(Second half): Complete Item 7 and submit

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS262 Project 3: Cruise Ship Manifest
30 $