Introduction To The SeaPort Project Series
Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define: ï‚· SeaPortProgram extends JFrame o variables used by the GUI interface o world: World ï‚· Thing implement Comparable o index: int o name: String o parent: int ï‚· World extends Thing o ports: ArrayList o time: PortTime ï‚· SeaPort extends Thing o docks: ArrayList o que: ArrayList // the list of ships waiting to dock o ships: ArrayList // a list of all the ships at this port o persons: ArrayList // people with skills at this port ï‚· Dock extends Thing o ship: Ship ï‚· Ship extends Thing o arrivalTime, dockTime: PortTime o draft, length, weight, width: double o jobs: ArrayList ï‚· PassengerShip extends Ship o numberOfOccupiedRooms: int o numberOfPassengers: int o numberOfRooms: int ï‚· CargoShip extends Ship o cargoValue: double o cargoVolume: double o cargoWeight: double ï‚· Person extends Thing o skill: String ï‚· Job extends Thing - optional till Projects 3 and 4 o duration: double o requirements: ArrayList // should be some of the skills of the persons ï‚· PortTime o time: int Eventually, in Projects 3 and 4, you will be asked to show the progress of the jobs using JProgressBar's. 2 Here's a very quick overview of all projects: 1. Read a data file, create the internal data structure, create a GUI to display the structure, and let the user search the structure. 2. Sort the structure, use hash maps to create the structure more efficiently. 3. Create a thread for each job, cannot run until a ship has a dock, create a GUI to show the progress of each job. 4. Simulate competing for resources (persons with particular skills) for each job. Project 1 General Objectives Project 1 - classes, text data file, GUI, searching ï‚· Define and implement appropriate classes, including: o instance and class variables, o constructors, o toString methods, and o other appropriate methods. ï‚· Read data from a text file: o specified at run time, ï‚§ JFileChooser jfc = new JFileChooser ("."); // start at dot, the current directory o using that data to create instances of the classes, o creating a multi-tree (class instances related in hierarchical, has-some, relationships), and o organizing those instances in existing JDK structures which can be sorted, such as ArrayList's. ï‚· Create a simple GUI: o presenting the data in the structures with with some buttons and o text fields supporting SEARCHING on the various fields of each class. Documentation Requirements: You should start working on a documentation file before you do anything else with these projects, and fill in items as you go along. Leaving the documentation until the project is finished is not a good idea for any number of reasons. The documentation should include the following (graded) elements: ï‚· Cover page (including name, date, project, your class information) ï‚· Design o including a UML class diagram o classes, variables and methods: what they mean and why they are there o tied to the requirements of the project ï‚· User's Guide o how would a user start and run your project o any special features 3 o effective screen shots are welcome, but don't overdo this ï‚· Test Plan o do this BEFORE you code anything o what do you EXPECT the project to do o justification for various data files, for example ï‚· Lessons Learned o express yourself here o a way to keep good memories of successes after hard work Project 1 Specific Goals: 1. Create a GUI 2. Let the user select a data file, using JFileChooser 3. Read the data file, creating the specified internal data structure (see the Introduction for the classes and variables of the structure). 4. Display the internal data structure in a nice format in the GUI 1. use JScrollPane and JTextArea 5. Display the results of a Search specified by the user 1. JTextField to specify the search target 2. Searching targets: name, index, skill would be a minimum you are encouraged to provide other options 3. Note that a search may return more than one item 4. DO NOT create new data structures (beyond the specified internal data structure) to search you may create a structure of found items as a return value Data file format: ï‚· Each item in the simulation will appear on a single line of the data file. ï‚· The data file may have comment lines, which will start with "//". ï‚· There may be blank lines in the data file, which your program should accept and ignore. ï‚· The data lines will start with an item type (port, dock, ship, etc.), an identifier, an index, and a parent reference or null, followed by class-specific attributes. ï‚· The fields on a line are space delimited. ï‚· The parent field indicates the relationship between items, linking child to parent by index. ï‚· Assume data file correctness and that parent links are encountered before their children. Sample lines include:
- // port name index parent(null)
- port Lanshan 1 null
- // dock name index parent(port)
- dock Pier_ 1 port
- // ship name index parent(dock/port) weight length width draft
- ship "Reason" 1 port 447.15 85.83 27.07
- // cship name index parent(dock/port) cargoWeight cargoVolume cargoValue
- cship Suites 1 port 125.09 176.80 857.43
- // pship name index parent(dock/port) weight length width draft numPassengers numRooms numOccupied
- pship "ZZZ_Hysterics" 1 port 327.92 56.43 30.0 4 3 2
- // person name index parent skill
- person "Sara" 1 port electrician
- // job name index parent duration requirements
- job "Job_10_94_" 1 port 0.78 carpenter cleaner clerk
The program should be tested with data files generated by CreateSeaPortDataFile.java, ensuring various scenarios are covered. The output in the GUI should list all ports, ships, persons, and queued ships, as shown in the sample output, formatted for clarity and readability.
--- End of assignment instructions ---
- // port name index parent(null)
- port Lanshan 1 null
- // dock name index parent(port)
- dock Pier_ 1 port
- // ship name index parent(dock/port) weight length width draft
- ship "Reason" 1 port 447.15 85.83 27.07
- // cship name index parent(dock/port) cargoWeight cargoVolume cargoValue
- cship Suites 1 port 125.09 176.80 857.43
- // pship name index parent(dock/port) weight length width draft numPassengers numRooms numOccupied
- pship "ZZZ_Hysterics" 1 port 327.92 56.43 30.0 4 3 2
- // person name index parent skill
- person "Sara" 1 port electrician
- // job name index parent duration requirements
- job "Job_10_94_" 1 port 0.78 carpenter cleaner clerk
The program should be tested with data files generated by CreateSeaPortDataFile.java, ensuring various scenarios are covered. The output in the GUI should list all ports, ships, persons, and queued ships, as shown in the sample output, formatted for clarity and readability.
--- End of assignment instructions ---