Question
Project Outcomes: Create a Java application that uses: decision constructs looping constructs basic operations on an Array of objects (find, change, access all elements) more
Project Outcomes:
Create a Java application that uses:
decision constructs
looping constructs
basic operations on an Array of objects (find, change, access all elements)
more than one class and has multiple objects
Prep Readings:
Absolute Java Chapters 1 6
Background Information:
The Unified Modeling Language (UML) provides a useful notation for designing and developing object-oriented software systems. One of the basic components of the UML is a class diagram, which are used to depict the attributes and behaviors of a class. A basic class diagram (as shown in the figure below) has three components. The first is the class name. The second component includes the class's attributes or fields. Each attribute is followed by a colon (:) and its data type. The third component includes the class's behaviors or methods. If the method takes parameters, their types are included in parentheses. Each behavior is also followed by a colon (:) and its return type. If the return value of a method is void, the return type can be omitted. For more information on the UML, refer to HYPERLINK "http://www.uml.org/" http://www.uml.org/.
Project Requirements:
This project will use The Vigenere Cipher to encrypt passwords.
Vigenere Cipher
Simple letter substitution ciphers are ones in which one letter is substituted for another. Although their output looks impossible to read, they are easy to break because the relative frequencies of English letters are known.
The Vigenere cipher improves upon this. They require a key word and the plain text to be encrypted.
Example:
Suppose you have a key word: house
We would encrypt a message as follows:
The first letter would be encrypted using these correspondences:
original letter: a b c d e f g h i j k l m n o p q r s t u v w x y z
substitute letter: h i j k l m n o p q r s t u v w x y z a b c d e f g
The second letter would be encrypted using these correspondences:
original letter: a b c d e f g h i j k l m n o p q r s t u v w x y z
substitute letter: o p q r s t u v w x y z a b c d e f g h i j k l m n
The third letter would be encrypted using these correspondences:
original letter: a b c d e f g h i j k l m n o p q r s t u v w x y z
substitute letter: u v w x y z a b c d e f g h i j k l m n o p q r s t
etc
Once all characters in the key are used, the offset repeats starting over with the Keys first letter.
The cipher for this program is a little more complex as you must include punctuation so the password may be any of the characters in the HYPERLINK "http://www.asciitable.com/" ASCII table from character 33 the exclamation point ! to character 122 the lower case z.
User Class
The class that contains user information including the username, password, encrypted password and key (see UML class diagram below)
User |
username : String clearPassword : String encryptedPassword : String key : String |
+User() +User(String, String, String) +getUserName() : String +setUserName(String) +getClearPassword(): String +setClearPassword(String) +getEncryptedPassword():String +setEncryptedPassword(String) +getKey(): String +setKey(String) -encrypt() +toString():String |
Constructors
Default constructor sets all fields to the empty String ()
Parameterized constructors
takes in the username, clearPassword and the key
calls the private method encrypt to encrypt the clearPassword using the Vigenere Cypher.
Methods
Accessor and mutator methods as listed in the Class Diagram
encrypt method
Private method only accessible to other methods of the User class.
Uses the Vigenere Cypher to encrypts the clearPassword instance variable using the key
Stores the encrypted password in encryptPassword instance variable.
toString returns a nicely formatted String representing the user to include username, encrypted password, clear password and key such as:
Jsmith ]Umka\f^ password house
Accounts Class
The Accounts class is what is known as a container class it contains multiple user objects.
The classs instance variable include company name, company address, number of elements stored in the array and an array of User Objects (see UML class diagram below)
Accounts |
companyName : String companyAddress : String users : User[] numOfelements: int NOTFOUND: int = -1 |
+Accounts() +Accounts(String, String, int) +getCompanyName(): String +setCompanyName(String) +getCompanyAddress(): String +setCompanyAddress(String) +addUser(User) +getUser(String): User +deleteUser(String) -findUser(String):int +toString(): String |
Instance Variables
users a partially filled array(Must use a partially filled array, no other API collection object allowed)
numOfElements the number of actual objects in the partially filled array.
Constructors
Default constructor sets company name and address to the empty String and creates a ten element array of User objects
Parameterized constructor sets the name and address to the appropriate instance variable and creates the array of User Objects. The size of the array is based on the integer parameter.
Methods
Accessor and mutator methods as listed in the Class Diagram
addUser
Takes in a User object
Adds that User object to the array(What else needs to be done as this is a partially filled array)
getUser
Takes in a String with the users username
Returns the User object from the array that is associated with that username.(assume unique username)
If the username does not exist
print out the error message: does not exist.
Return null
Calls the private findUser method to locate the index of the User object in the array.
deleteUser
Takes in a String with the users username
Returns true if user found and deleted, false if user not found
Calls the private findUser method to locate the index of the User object in the array.
Reorganizes the array so there are no empty or null objects in the array. (Hmm.Think about an efficient way to do this)
findUser
Private method that takes in a String representing a username
Searches the array looking for this username (again assume usernames are unique)
If found, returns the array index of the username
If not found returns NOTFOUND constant.
toString
returns a nicely formatted String table representing a all the users information in the array(see example below)
use of the User toString method is advisable.
ABC Company 1234 Holly Lane, Pensacola Florida Username EncryPass ClearPass Key Jsmith ]Umka\f^ password house
mjones GYOX)r*z abcd1234 argos
AccountTester
The purpose of this class is to thoroughly test all the methods and constructors in the Accounts and User classes.
Methods can be tested directly or indirectly
Indirect testing is testing a method by calling another method such as
If the constructors calls the mutator methods when setting instance variables rather than setting them directly.
If the toString method calls accessor method rather than accessing instance variables directly
No user input, just create variables and/or hardcode values
To simplify the program some, No error handling required
All passwords are 8 legal characters(as outlined in the requirements)
All keys are 5 characters
Program Flow (suggestion)
Create several User Objects
Add each to the Accounts class
Call the Accounts toString
Search for username including one that is not found.
Delete a user account.
Call Account toString before exiting.
Programming/Client Communication
When developing a program requirements are rarely perfect, ambiguities, omissions and errors are usually present.
To keep this communication organized please post to the appropriate Programming Project Topic any question you may have. I will answer those question there and thus we will have a written record.
If you ask a question in class, I will answer it but you need to post the question as well.
Submission Requirements:
Your project must be submitted using the instructions below. Any submissions that do not follow the stated requirements will not be graded.
1. You should have the following files for this assignment:
User.java - The User class
Accounts.java The collection class for User information.
AccountTester.java The testing class for this project
The javadoc files for all the User and Accounts classes (Do not turn in)
User.html
Account.html
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started