代写 data structure algorithm GUI Java SQL UML XML database graph Data Structures and Algorithms Assignment 3: 50 Marks, Worth 10% of final grade Due: 18 October 2019

Data Structures and Algorithms Assignment 3: 50 Marks, Worth 10% of final grade Due: 18 October 2019
Please zip up your entire project folder and submit to Blackboard before 11.59pm on the due date. Ensuring all java, xsd, xml and jpg images are included.
The class Patient (Done for you) from Blackboard in the Assignment 3 folder, represents a record for a single patient waiting for a medical doctor at a local general practitioner. Its methods and fields are described in the UML below:
Patient
– nhiNumber : String
– name : String
– gender : char
– age : int
– address: String
– symptoms : String
– treatment : String
– picURL : String
– image : ImageIcon
– displayPanel : JPanel
+ Patient(nhiNumber: String)
+ Patient(nhiNumber: String, name : String,
gender : char, age : int, address : String) + getNHI() : String
+ getName() : String
+ setName(name : String) : void
+ getGender() : char
+ setGender(gender : char) : void
+ getAge() : int
+ setAge(age : int) : void
+ getAddress() : String
+ setAddress(address : String) : void
+ getSymptoms() : String
+ setSymptoms (symptoms: String) : void
+ getTreatment() : String
+ setTreatment (treatment : String) : void + loadImage(fileName : String) : void
+ getPicURL() : String
+ getDisplayPanel() : JPanel
+ toString() : String
+ main(args : String[]) : void
The class contains a unique patient identifier (an NHI number), name, age and other attributes for a patient including illness symptoms and treatment required for healing. The class has suitable accessor and mutator methods for most of the class attributes. The class also allows an optional image to be associated with a patient which can be loaded in by passing in its file location into the loadImage method. For convenience, all patient information can be displayed and updated in a JPanel, which can be viewed by any GUI. This can be done by calling the getDisplayPanel method returning a panel filled

with editable components. The class has a main method to set up a basic frame to display one Patient for testing.
Question 1) PatientRecords (15 marks)
Using the UML below, create a class called PatientRecords which encapsulates a suitable Java data structure which can be used to efficiently obtain Patient objects from an NHI number (no need to implement your own, use an existing data structure). It has a default constructor and another constructor which can be given an XML document, in which it uses DOM to extract Patient objects from XML content (you may use DOMUtilites from chapter 4 to assist the extraction process). The extracted XML file should validate with the patient.xsd schema (on Blackboard along with sample XML file). It has methods to add, remove and get appropriate Patient objects, and a method to get all patient NHI values as a String array.
PatientRecords
– someEncapsulatedSuitableDataStructure
+ PatientRecords()
+ PatientRecords(document : Document)
+ getNumberOfPatients() : int
+ getPatient(nhiNumber : String) : Patient
+ removePatient(nhiNumber: String) : boolean + containsPatient(nhiNumber: String) : boolean + addPatient(patient : Patient) : void
+ getPatientNHIs() : String[]
Create a suitable main method to test Patient and PatientRecords. Question 2: PatientRecordGUI (10 marks, + 5 bonus marks)
Create PatientRecordGUI which shows a graphical representation used to view multiple patients enrolled at general practitioners office which are held in the PatientRecords data structure.
• The GUI should keep a field for PatientRecords in which new Patient objects can be added, viewed or removed.
• A JList maintaining a list of selectable NHI numbers used to view each individual Patient object. This in turn will display the Patient’s underlying display panel (using its getDisplayPanel method). Add the JList and selected patient display panel to a JSplitPane, if nothing is selected then use an empty panel.
• A JButton for adding a new Patient initially with just a unique NHI – the other information to be filled in by the user.
• A JButton for displaying a JFileChooser to load an XML file of all Patient objects.
• A JButton for removing a selected Patient.
• A JButton to load a selected image for the currently displayed Patient.
Make sure your program handles any unexpected user inputs and exceptions. A screenshot of the GUI can be seen below:

BONUS 5 Marks: Add another button to your panel which can save the Patient objects held in PatientRecords to a selected XML file.
Question 3) Shipping Journey. (10 marks)
The next part of this assignment is to create a program that uses the Shipping and Ports tables of the testRestricted database on the raptor2.aut.ac.nz server. These tables hold a list of ports and boat trips between ports. You can access this database through any SQL front end client (or Netbeans). Use the username “student” and password “fpn871”
Obtain the class called BoatTrip from Blackboard which represents a single boat trip between two different ports. The class keeps track of the departure and arrival times and names of the ports that the boat is travelling between, the cost of the trip and the boatID.
Using the following UML diagram below, create a class called Journey which represents a set of boat trips (path) between multiple ports. The class holds a boatTripList of BoatTrip objects. There are two constructors, one default and another that adds a list of boat trips to the boatTripList. The addTrip method should add a BoatTrip only if the Journey so far does not contain its arrival port. Any newly added BoatTrip should also be checked to make sure its departure port matches the current Journey’s end port. The containsPort method should return true if the given port is in this Journey so far. The get methods return the start and end ports and dates or null if the Journey does not contain a boat trip. The removeLastTrip removes the lastly added BoatTrip from the Journey. The createClone method returns a clone of the current Journey by passing its boatTripList instance to the second

constructor. The getJourneyCost should return the total cost of all the boat trips in the current Journey. The toString method should print out a string representation of all boat trips in this journey and the total cost.
Journey
– boatTrips : LinkedList
+ Journey()
+ Journey(list : List)
+ addTrip(trip : BoatTrip) : boolean
+ removeLastTrip() : boolean
+ containsPort(port : String) : boolean + getStartPort() : String
+ getEndPort() : String
+ getEndDate() : String
+ createClone() : Journey
+ getJourneyCost() : int
+ toString() : String
Question 4) Shipping Centre: (15 marks)
Prepare a class called ShippingCenter that reads from the Shipping and Ports tables in the SQL database. The readAllPorts method should return a list of all the ports in the database from the Ports table. The getAllJourneys method starts a journey from the startPort to the endPort departing from a certain date. It calls the recursive method findPaths which performs a depth-first search of all the possible paths that a Journey can take between the start and end ports. Once complete a list of all the possible journeys is returned back to the user. The findPaths method should query the database table Shipping to get all the paths that leave from the current port after the date that the trip arrives rather than reading in the entire database.
ShippingCompany
-conn : Connection
-stmt : Statement -journeyList : List
+ShippingCompany(dbUser : String, dbPassword : String) +readAllPorts() : List +getAllJourneys(startPort:String,startDate:String,
endPort:String) : List -findPaths(currentJourney:Journey, startDate:String,
startPort:String, endPort:String) :void +close() : void
+main(args : String[]) : void
Create a suitable main method which creates a ShippingCompany instance, connecting to the raptor2 database. It then should ask the user for a start and end port and start date (all trips leave after 1 January 2020) and obtaining and outputting all possible paths found between those ports.

A demo screenshot of the console output is seen below: