Escolar Documentos
Profissional Documentos
Cultura Documentos
Purpose: You are going to learn how to implement a linked list and deepen your understanding
of object-oriented design.
Requirements: To complete this project you will write five classes and one text file.
Create a file Account.java which is a class representing a very basic checking account. An
account has a firstName (String), lastName (String), accountID (unsigned integer), and
currentBalance (double). You should create appropriate constructors and accessors/mutators
for each of these values. You should also create a method
public String toString()
o Returns a String in the form accountID, lastname, firstname,
currentBalance
o Example: 481516, Mkrtchyan, Katya, $23.42
Note, monetary values must be printed in the form $DD.cc
Where DD is the dollar amount and cc is the number of cents (0-
padded to 2-digits)
Create a file AccountNode.java. It will hold an instance of an Account as well as a next and
previous pointer (to other AccountNodes). It will have accessors and mutators for next/prev
pointers.
Create a file called Driver2.java which contains a java program. This program will instantiate
an OrderedVectorOfAccounts and a LinkedListOfAccounts, and will read from a file called
accounts.txt to initialize both data structures. Then the program will allow user interaction. See
the same accounts.txt file and user interaction below.
Once you have finished programming and debugging your code, time both data structures using
System.currentTimeMillis(). Try these tests:
inserting 1000 items
inserting 500 items and then deleting each
inserting 1000 items and then performing 10000 finds
Write a file named Analysis.txt where you describe the performance of the
LinkedListOfAccounts and the OrderedVectorOfAccounts on each of these tests. Explain why
you obtain these results.
Grade Breakdown:
15%: Submission instructions followed to the letter (5 .java files and 1 .txt file, named as stated
above)
20%: Code compiles without error
30%: Code functions as per this spec
15%: Code has proper indentation, style (~30 line routines, 80 chars per line), layout as per
spec, and comments where appropriate
20%: Analysis.txt contains results of tests and appropriate analysis
Cheating: This project (like all projects in this class) is an individual project. You can discuss
this project with other students. You can explain what needs to be done and give suggestions
on how to do it. You cannot share source code. If two projects are submitted which show
significant similarity in source code then both students will receive an F in the course. Note a
person who gives his code to another student also fails the class (you are facilitating the
dishonest actions of another).
Sample accounts.txt:
This file consists of 4 lines for each account (lastName, firstName, accountID, currentBalance)
Kwon
Sun
77665
408 16
Mkrtchyan
Katya
90210
555 66
Norris
Chuck
75007
998700 20
Sample Interaction:
Welcome to Project 3
Reading data from accounts.txt
Enter a command
> asdfghjk
Enter a command
> help
Commands are:
account (add a new account)
close (remove an account)
find (display one account)
deposit (add money to account)
withdraw (remove money from account)
help (print this screen)
quit (end the program)
Enter a command
> account
Enter a command
> find
Enter a command
> close
Enter a command
> close
Enter a command
> deposit
Enter a command
> withdraw
Enter a command
> quit