• No results found

Project 4 DB A Simple database program

N/A
N/A
Protected

Academic year: 2021

Share "Project 4 DB A Simple database program"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

Project 4 – “DB” – A Simple database program

Due Date

• April 10 (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. (10 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.

(2)

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);

(3)

/* 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 10 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

(4)

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;

(5)

Project 4: “DB”

Student Name

Date Submitted, Days Late, Late Penalty

Graded Item Points

Assigned Comments

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

10

Step 1-6: Basic operations Functionality

void insert(Student student);

boolean delete(String gNumber);

String toString();

Student find(String gNumber);

Save and load serializable;

50

Step 7: Basic operations Functionality

• JUnit tesing

10

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)

10 Max Possible Points 100

Additional Comments: (How many hours did you spend developing this project?)

References

Related documents

Western Kentucky has already jumped out to an impressive 4-2 record with impressive wins at home over (ieorgia and Southern Illinois and an enormous victory on a neutral court

In this case the researchers see the real world as a human activity systems using three level of New Intitutional Economic and Sociology (NIES) (Nee, 2003) by using

Instead of using FTP or similar approaches for pushing files around a network, Progress DataDirect Bulk Load quickly loads the data you need into relational database tables..

We have worked over the last four semesters to infuse testing and JUnit across our curriculum, building from having students use JUnit to having them write their own test cases

Networking in increasing the android new hashmap using system class does not an predefined size put new capacity and notify in the built data.. Age with coding by java and is the

contracts, discourses are text, social media content comes as JSON documents, open data is often structured in RDF graphs etc.; (iii) an answer stating, e.g., that a certain

Stage 3 presents exposed necrotic bone associated to pain, soft tissue inflammatory swelling or secondary infection difficult to manage with oral or intravenous antibiotic

 Presence of cancer care infrastructure such as medical laboratory, ultrasound facilities, X-ray facilities, Radio- and chemo- therapy facilities, nuclear