Objectives: Upon completion of this assignment you need to be able to:
- Practice creating a class that implements an interface in Java.
- Use the Node class to create a reference-based list.
- Use Exception Handling techniques.
- Read and understand specifications.
- Implement testing of code during development.
______________________________________________________________________________
Resources:
- CSC 115 Java Coding Conventions.pdf (found on conneX, under Resources)
- Textbook Chapters 4 and 5.
- java
- java
- java
- java
- java
Introduction:
A local pharmacy would like to keep a small database of its clients and a list of the medications that each patient is currently taking. For now, it is confined to local residents, but the pharmacy is hoping to tap into the larger region and include communication with the hospitals. We are tasked with supporting a basic system that will monitor medication lists to later attach to patient files. Since most people are not on huge numbers of mediation, we decide to use the basic List ADT to manage each patients medication information. We havent decided whether to use an array based list or a reference based list, so we will implement both. That way we can plug in whichever one suits the clients needs, without having to alter the clients handling of the lists. The array-based medication list has already been completed and tested. We need to complete the reference-based list.
In this assignment you will:
- Develop the MedListRefBased class that implements the standard List interface approved by the client.
- Use the doubly-linked list as the primary data field in this class; it is described in the textbooks Chapter 5 beginning on page 280.
Quick Start:
- If you havent done so already, download all the necessary documents for this assignment from conneX into a specific folder for CSC115 assignment two, assn2 is a recommended name.
- Double-click on the html to see the specifications for a standard List interface. It is similar to the ADT description on the Text page 204. The List.java file contains all the method headers required of any class that implements a list. Note that none of the methods contain a body; the implementation is never part of an ADT. Note also that the description uses Java generics, described on page 291. This allows the developer of a List to make the decision of the type of elements E that will be stored in the list.
- Examine the completed source code for the MedListArrayBased Note that it implements List<Medication>, allowing for any object of the MedicationArrayBased to also call itself a List object. Note also that MedListArrayBased implements every method of the List interface. Similarly to the file in Assignment one, there is a main method where internal testing of each method is carried out. Internal testing allows a programmer to test all methods, including the private methods during the development phase.
- Examine the file called java. This is an example of an external tester. It is the tester that is used once the completed class is ready for its final assessment before submitting it to the client. Note that it can only test the methods that are listed in the List ADT. It tests the list for functionality from the perspective of a user, the pharmacy in this case.
- Compile all the given java files. You can run MedListArrayBased to examine the internal tester result. You can also run the MedListTester to examine the external test results.
- Your job is to create a class called MedListRefBased that implements List<Medication>. It must contain all the required public methods and implement the list using a doubly linked list instead of an array. See Chapter 5 for information on the doubly linked list.
- Once the code for MedListRefBased is completed and internal testing is done, you can use the external tester after changing a portion of a single statement in the tester.
Detailed Instructions
There are several files supplied in this assignment. Examine them many times; their purpose makes sense as you work on the implementation of the linked list version of the medication list. You only need to create one class. Once that is done, you will need to alter the external tester
class so that it calls the MedListRefBased constructor instead of the MedListArrayBased constructor.
You are to create, implement and test the MedListRefBased class. Make sure of the following:
- The main data structure you use to store the medications is a doubly linked list, that you create yourself (no util classes are to be used in your source code).
- The class implements List<Medication>.
- Any private methods are properly commented (follow the MedListArrayBased source code as a guide.) Note that comments are not required for any method that implements a method required by the List Those methods are already commented and the methods you implement will follow those specifications. During the labs, you will be introduced to javadoc, a tool to create proper documentation.
- The main method inside your source code tests each of your methods. Use this extensively to check the progress, including the private helper methods. You do not need to comment out the main method or delete it. The marker will be looking for evidence of internal testing.
- Once you have thoroughly tested all the methods internally, then you can move onto the external tester. If the external tester fails, then you must go back to the internal tester and take the necessary steps to debug and fix your code. The external tester will test your program when you alter the one line in java that declares the List list variable and initialize it with a call to the MedListRefBased constructor. Then re-compile and run MedListTester. You should see exactly the same output as when it tested the MedListArrayBased class.
Submission
Submit the following completed file to the Assignment folder on conneX:
- java
Please make sure that conneX has sent you a confirmation email. Do not send [.class] (the byte code) file, or any another file for this assignment. Also make sure you submit your assignment, not just save a draft. All draft copies are not available to the instructors, so we cannot mark them.
Note about Academic Integrity: It is OK to talk about your assignment with your classmates, and you are encouraged to design solutions together, but each student must implement (code) their own solution.
We will be using plagiarism detection software on your assignment submissions.
Reviews
There are no reviews yet.