Objective: To learn Objective-C well enough to do a late cs1 or
early cs2 project in objective-c
Due: Feb 11th 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 in objective-c. (note my comp152 students are doing a
very similar lab
Details:
Get the sample input file.
You will need to write at least two classes and a third file with a main
function.
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:
(BOOL) 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
(BOOL) canOpenDoor:(int) cardNumber
DoorIndex:( 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.
Finally write a class or function which will create the LockDataBase object,
then allow a user to enter a card number and a door. The program should
query the LockDataBase object and then tell the user if the door would open
for this user or not.
Submitting:
Include a readme.txt text file in your project. For this project the
readme.txt should include
- your name
- your approach. Did you use something that we didn't reviw in class?
What did you do to implement the project?
- Anything that is still not done when you submit.
When you are ready to submit your project zip up the folder with the
objective-c code, your sample input file and your readme and upload them
to moodle.