Comp 152 Project 1:
Review of Comp 151
Objective: to review many of the key concepts of comp151 to
refresh your programming knowledge and get everyone ready for this
semesters programming projects on new topics.
Due: Feb 10th at 11:59pm
Summary:
In this project you will write a program which will be a simplified
version of software to run the card access doors in a building like the
science building.
Details:
Go to the moodle page for the class and download the three starter files.
You will find the sample input file and two programming files. They won't
compile immediately because they rely on one of the classes you will write
below. Import review.java and Window.java into your implementation of this
project. Put lockDataBase.txt into your working directory. (In eclipse
this is the main project directory, when using the command line, this is
the folder with the object files in it.
You will need to write two classes. The first class will be called
LockData and store data about whether a particular card has access to a
series of locks.
LockData must store the following information (this will be private so you
can represent this however you like:
- a card ID which should be a whole number
- a name which should be text
- a set of 8 permissions, each of these 8 permission will represent one
door. This could be stored as booleans, integers or whatever you like.
you must also make the following method available:
public boolean checkDoorPermissions(int doorNumber)
behavior: This method will take an integer from 0 to 7 representing one of 8
doors. It will return true if this card's owner (this object) should open
the door numbered doorNumber. The method should return false otherwise. Of
course you will need other methods like constructors and accessor methods,
but just fill in those that you need.
Your second class must be called LockDataBase. It needs to:
- have a collection (either an Array or an ArrayList, your choice) of
LockData objects. If you go with an array make sure you can handle at
least 25 elements.
- have a method which will read from a file named lockDataBase.txt (note
that when I grade I will add additional lines to the sample file I'm
giving you with this assignment.
- each line of the file will have the following format:
<card number> <lock access permissions> <card
holder name>
for example: the first line in the sample file is
23456 10101010 John Santore
- 10101010 is the lock access permissions
- there are 8 numbers (either a zero[no access] or a one[access to
this door]), one for each of the 8 locks. The first number is
whether the card should open lock 0, the second number of whether
the card should open lock 1 and so on.
- so in the example above, this user has access to doors 0,2,4 and
6 and no access to doors 1,3,5 & 7
- everything that is left on the line is the name of the user.
- After the user reads each line of the file into the program, make a
LockData object out of the line and put it into your array.
- Call your method for reading from the file in your constructor for the
LockDataBase class. You must provide a zero parameter constructor.
- Provide the following method as part of your LockDataBase class
public boolean canOpenDoor(int cardNumber, int doorNumber)
- This method should use the first parameter, cardNumber, to search
through the array(List) of LockData objects to find the right lockData
object. Then call the
checkDoorPermissions
method
passing doorNumber. The return value of the method must be whether
this card should open the doorNumber specified. If there is no
LockData for this card number, return false.
Submitting:
Include a readme.txt text file in your project. For this project the
readme.txt should include
- your name
- two or three sentences about which part of the project you had to do
the most reviewing to complete
- Anything that is still not done when you submit.
When you are ready to submit your project zip up the folder with the java
code, your sample input file and your readme and upload them to moodle.