Project 4 DB A Simple database program Due Date April (Friday) Before Starting the Project Read this entire project description before starting Learning Objectives After completing this project you should be able to: Create and manipulate linked lists and stacks Create your own OO design Write to and read from files Program Description Your assignment is to develop a program that implements a simple database program. Your program should be able to insert, delete, save, load, clear, display and edit. This database will hold student information such as, the student s name, G number, and GPA. (Other information would be maintained in another database, such as, the student local and permanent address, phone number, transcripts, and so on. However, for this project that information will not be included since it is a student project.) A fully implemented database (DB) will have the following functionality: Insert, delete and update a student into the DB Save and load the DB display the DB (Display the entire database) sort the DB ( Make this only available as a JMenu item) reverse the DB (Reverse, see notes below) undo operation (multi-undo operations) Remove duplicate (use the G number to determine a duplicate) Also do JUnit testing on your code. Steps 1 6 should be completed as a group. Steps 7 11 should be done after Steps 1 6, and 7-11 can actually be done in any order. Before you turn in your work: use the Java Style Guide to document your project. ( pts) Step 1: Create an Eclipse project named SimpleDatabasePrj Create a package named: package1 Create a class named: GUISimpleDatabase Create a class named: SimpleDatabasePanel // see Step 4 for details Create a class named: SimpleDatabase o Create a class named: Node // see Step 2 for details. o Create a class named: Student // see Step 3 for details. OTHER classes can be created without the instructor s approval. Step 2: Implement the class Student with the following properties. Include get and set methods were needed, and implement required methods from interface Comparable. 1
public class Student implements Comparable<Student> { private String name; private String gnumber; private double gpa; Step 3: Implement the class Node with the following properties. Include get and set methods where needed. private static class Node { public Student data; public Node next;... Actually type this class Node inside class LinkedList (which is specified next). Step 3 3/4: Implement the class "LinkedList" with the following properties: public class LinkedList implements Serializable { private int count; // The number of Nodes in the list private Node head; // a dummy Node at the front of the list... Step 4: Implement the class named: SimpleDatabasePanel. This GUI interface is only used to help demo your program. Make it simple since JUnit testing is the process in which your program will be tested. Using the programs found in chapter 6 of your book as a guide, create a main method that creates a JPanel object (SimpleDatabasePanel). The following is a suggestive screenshot; be sure to have appropriate input boxes, and appropriate scrollable output. Also, there are operations not included in this screen shot in the later steps of this project. Step 5: Java Interface to Implement You must include the following java interface ISimpleDatabase in your project. Important: For this step you are only required to implement: insert, delete, find, display. Have the class called SimpleDatabase that was specified in step 1 implement this ISimpleDatabase interface. interface ISimpleDatabase { /* used to insert a student into the DB, PLACE the STUDENTS in order based up */ /* the student's name */ void insert(student student); /* used to delete a student from the DB, use the to find the student */ boolean delete(string gnumber); 2
/* Use the gnumber to find the student */ /* you may only update the student's name and GPA. Not their gnumber */ boolean update(string gnumber, Student student); /* returns a string of the entire DB */ String tostring(); /* finds a Student, otherwise returns null */ Student find(string gnumber); /* reverses the database (see notes below) */ void reverselist(); /* removes duplicates from the database) */ void removeduplicates(); /* Sort the db using the compareto method contained in the Student class. */ /* Be sure to implement the comparable interface in the Student class */ /* sort by student's name, use the String.compareTo method */ void Sort(); /* undo the previous command */ boolean undo(); } /* Loads/saves using files, JUnit testing will test only these load * and save methods */ void loaddb(string filename); void savedb(string filename); Step 6: Create save and load methods with Serializable files Required: You are to create two versions, /* Loads/saves using String filename and the JUnits test using these methods */ void loaddb(string filename); void savedb(string filename); Step 7: Create many (lots and lots) of JUnit test cases that show your program functioning. JUnit testing is worth pts for your project! You must show through multi-test cases that your program is functioning correctly. Remember, the ISimpleDatabase interface is what the JUnit uses to test methods. For the following steps, please see the instructor if you have any questions, or concerns. Step 8: Implement the reverselist method. You are required to move the references (pointers) and not the data. Hence, a stack is not allowed. Step 9: Implement the removeduplicates. Find all students with the same gnumber, name and GPA. Remove all but one. In other words, one of the students should remain. Step A: Have the Student class implement the Comparable interface, and write a 3
sort() method that sorts the DB using the compareto() method. Specifically, sort the list according to students names using String.compareTo(). Step B: Implement an UNDO button that would be able to undo previous operations. The following operations should be able to be undone: Insert, delete, reverse, remove- Duplicates, sort, update. (NOTE: allow multi undos). Note: When a save or load operation is done, then reset the undo. That is, reset the undo- s stack immediately after a load or a save. Solution: save off the entire database every time a new operation was done. Talk to the instructor about how best to implement this operation. Step C: Re-implement the Node and LinkedList classes to make them a double linked list and have a dummy Node at the end of the list. public class Node { public Student data; public Node next; public Node prev; 4
Project 4: DB Student Name Date Submitted, Days Late, Late Penalty Graded Item Javadoc Comments and Coding Style/Technique (http://www.cis.gvsu.edu/studentsupport/javaguide) Code Indentation (auto format source code in IDE) Naming Conventions (see Java style guide) Proper access modifiers for fields and methods Use of helper (private) methods Using good variable names Header/class comments Every method uses @param and @return Every method uses a /***************** separator Overall layout, readability, No text wrap Using /** / for each Instance variable Has many inner inner comments Step 1-6: Basic operations Functionality void insert(student student); boolean delete(string gnumber); String tostring(); Student find(string gnumber); Save and load serializable; Step 7: Basic operations Functionality JUnit tesing Points Assigned 50 Comments Step 8: Reverse List functionality 5 Step 9: Remove Duplicates functionality 5 Step A: create a sort method / comparable 5 Step B: Undo functionality 5 Step C: Make it a doubly linked list (Keep a backup copy of your single linked list) Max Possible Points 0 Additional Comments: (How many hours did you spend developing this project?) 5