Question

Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...

Java

Project Requirements:

  1. Account class
    1. Superclass
    2. Instance variables
      1. clearPassword
        1. String
        2. Must be at least 8 characters long
      2. encryptedPassword : String
      3. key
        1. int
        2. Must be between 1 and 10(inclusive)
      4. accountId - A unique integer that identifies each account
      5. nextIDNum – a static int that starts at 1000 and is used to generate the accountID
      6. no other instance variables needed.
    3. Default constructor – set all instance variables to a default value.
    4. Parameterized constructor
      1. Takes in clearPassword, key.
      2. Calls encrypt method to create encryptedPassword
    5. setClearPassWord(String newPassword)
      1. Takes in a new clear text password.
      2. Calls encrypt method as the encrypted password would need to change.
    6. no encryptedPassword mutator method
    7. setKey(int newKey)
      1. Takes in a new key
      2. calls encrypt method as the encrypted password would need to change.
    8. accountId mutator - uses the static variable nextIDNum to retrieve the next available userID number
    9. encrypt method
      1. Uses the instance variables clearPassword and key to encrypt the password.
      2. Stores the encrypted password in the encryptedPassword instance variable
    10. toString - returns a nicely formatted String representing the instance variables of the Account class

NOTE: Your Account class should ensure the clearPassword is valid as described in the requirements.   If not write an error message to the standard output and continue. Set the clearPassword and encyrptedPassword to the empty String.

  1. User Class
    1. Subclass of Account class.
    2. Instance variables
      1. username – String
      2. fullName – String
      3. deptCode – int representing the department code
      4. No other instance variables are needed.
    3. Methods
      1. Default constructor sets all instance variables to a default value
        1. Call the super class constructor passing appropriate parameters to it.
        2. Set the rest of the variables
      2. Parameterized constructors
        1. Call the super class constructor passing appropriate parameters to it.
        2. Set the rest of the variables to the remaining parameters
      3. Accessor and mutator methods for all variables in this class
      4. toString
        1. Calls super class methods as needed.
        2. Returns a nicely formatted String representing the user to include fullName, username, deptCode, accountID number, clearPassword, encryptPassword and key
  1. Bot Class
    1. Subclass of Account class.
    2. A class that stores information about an application that performs an automated task.
    3. Instance Variables
      1. botFileName – String representing the file name of the bot
      2. category – String providing the Bot category which will be either IDS, SysAdm, or HelpDesk.
      3. dateUpdated – GregorianCalendar object (from the Java API) that shows the date the Bot was last updated.
      4. createdBy – String representing the creator name or handle.
    4. Methods
      1. Default constructor sets all instance variables to a default value
        1. Call the super class constructor passing appropriate parameters to it.
        2. Set the rest of the variables
      2. Parameterized Constructor
        1. Takes in all parameters required to set the instance variables.
        2. Call the super class constructor passing appropriate parameters to it
        3. Set the rest of the variables to the remaining parameters
        4. Date is a String in the format mm/dd/yyyy.
        5. Convert the date to a format compatible with creating GregorianCalendar object.
        6. Create the GregorianCalendar object
      3. Accessor and mutator methods for all variables in this class.
      4. toString
        1. Calls super class methods as needed
        2. Returns a nicely formatted String representing the Bot to include Bot file name, purpose, date updated, creator name, accountID number, clearPassword, encryptPassword and key
  1. The AccountTester
    1. This class should consists of a main method that tests all the methods in each class, either directly by calling the method from the Tester or indirectly by having another method call a method.
    2. User and Bot information will be read from a file. A sample file is provided. Use this file format to aid in grading. Using file processing makes entering and testing program with data sets much more efficient.
    3. The file created should include valid and invalid passwords that fully tests the application.
    4. Included is file called data.txt contains Account data. Your project will be graded using a similar input file. Your project must run with an input file formatted as data.txt is formatted. Note the file format is as follows:
      1. Character designation of type of player ( u- User, b - Bot)
      2. User – username,fullname,deptCode
      3. Bot – botFilename,category,dateUpdated,createdBy
      4. Account data – common data for both types
    5. Creates an array of Account objects.
      1. Populate the array with both User and Bot objects.
      2. Retrieves each object stored in the arrau and calls its toString method polymorphically and displays the results.
  1. Create UML Class Diagram for the final version of your project. The diagram should include:
    1. All instance variables, including type and access specifier (+, -);
    2. All methods, including parameter list, return type and access specifier (+, -);
    3. Include Generalization and Aggregation where appropriate.
    4. The AccountTester does not need to be included.
    5. Refer to the UML Distilled pdf on the content page as a reference for creating class diagrams

You should have 10 files for this assignment:

  • User.java - The User class
  • Bot.java - The Bot class
  • Account.java – The Account class.
  • AccountTester.java A driver program for your project
  • data.txt - your test file
  • Simply UML Class diagram of your 4 classes, do not include the Tester. (Dia file or image file , jpg, gif, pdf etc)
  • The javadoc files for all the classes except the tester.(Do not turn in)

This is what I have so far

public class Account {

    private static int nextIDNum = 1000;

    private String clearPassword;
    private String encryptedPassword;
    private int key;
    private int accountID;

    public Account() {
        this.clearPassword = "";
        this.encryptedPassword = "";
        this.key = 0;
        this.accountID = nextIDNum;
        updateNextIDNum();
    }

    public Account(String clearPassword, int key) {
        if (clearPassword.length() >= 8 && 1 <= key && key <= 10) {
            this.clearPassword = clearPassword;
            this.key = key;
            this.encryptedPassword = "";
            encrypt();
        } else {
            System.out.println("ERROR::Minimum password length should be 8
" +
                    "Key should be between [1 and 10]");
            this.clearPassword = "";
            this.encryptedPassword = "";
            this.key = 0;
        }
        this.accountID = nextIDNum;
        updateNextIDNum();
    }

    private void encrypt() {

        for (char letter : clearPassword.toCharArray()) {
            char shift = (char) (((letter + key) % 90) + 33);
            encryptedPassword += shift;
        }
    }

    public void setClearPassword(String clearPassword) {
        this.clearPassword = clearPassword.length() >= 8 ? clearPassword : this.clearPassword;
        encrypt();
    }

    public void setKey(int key) {
        this.key = (1 <= key && key <= 10) ? key : this.key;
        encrypt();
    }

    public void updateNextIDNum() {
        Account.nextIDNum++;
    }

    @Override
    public String toString() {
        return "Account ID: " + this.accountID + ", Encrypted Password: " +
                this.encryptedPassword + "      ["+ key+"]:Key" ;
    }


    public static void main(String[] args) {

        Account account  = new Account("SScret#123",7);
        System.out.println(account);
    }
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here are the User and Bot java classes. In order to write the Tester driver class need the input file to implement the class.

_______________________________________________________________________________________________

public class User extends Account {
    private String userName;
    private String fullName;
    private int deptCode;

    public User() {
        super();
        this.userName = "";
        this.fullName = "";
        deptCode = 0;
    }

    public User(String clearPassword, int key, String userName, String fullName, int code) {
        super(clearPassword, key);
        this.userName = userName;
        this.fullName = fullName;
        this.deptCode = code;
    }


    @Override
    public String toString() {
        return "Username: " + userName +
                "Fullname: " + fullName +
                "Dep Code: " + deptCode +
                super.toString();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public int getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(int deptCode) {
        this.deptCode = deptCode;
    }
}

_______________________________________________________________________________________________

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Bot extends Account {

    private String botFileName;
    private String category;
    private GregorianCalendar dateUpdated;
    private String createdBy;

    public Bot() {
        super();
        this.botFileName = "";
        category = "";
        DateFormat ndf = new SimpleDateFormat("dd/MM/yyyy");
        dateUpdated = new GregorianCalendar();
        createdBy = "";
    }

    public Bot(String clearPassword, int key, String botFileName, String category, GregorianCalendar dateUpdated, String createdBy) {
        super(clearPassword, key);
        this.botFileName = botFileName;
        this.category = category;
        this.dateUpdated = dateUpdated;
        this.createdBy = createdBy;
    }

    @Override
    public String toString() {
        return "File name: " + botFileName +
                "Category: " + category +
                "Updated on: " + dateUpdated.get(Calendar.MONTH) + "/" + dateUpdated.get(Calendar.DAY_OF_MONTH) + "/" +
                dateUpdated.get(Calendar.YEAR) + " " +
                "Created by:" + dateUpdated +
                super.toString();
    }

    public String getBotFileName() {
        return botFileName;
    }

    public void setBotFileName(String botFileName) {
        this.botFileName = botFileName;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public GregorianCalendar getDateUpdated() {
        return dateUpdated;
    }

    public void setDateUpdated(GregorianCalendar dateUpdated) {
        this.dateUpdated = dateUpdated;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }
}

_______________________________________________________________________________________________

Add a comment
Know the answer?
Add Answer to:
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java: Please help with my Tester. I'm having a hard time figuring out my error. Thank...

    Java: Please help with my Tester. I'm having a hard time figuring out my error. Thank you. What the tester requires: The AccountTester This class should consists of a main method that tests all the methods in each class, either directly by calling the method from the Tester or indirectly by having another method call a method. User and Bot information will be read from a file. A sample file is provided. Use this file format to aid in grading....

  • 1.     This project will extend Project 3 and move the encryption of a password to a...

    1.     This project will extend Project 3 and move the encryption of a password to a user designed class. The program will contain two files one called Encryption.java and the second called EncrytionTester.java. 2.     Generally for security reasons only the encrypted password is stored. This program will mimic that behavior as the clear text password will never be stored only the encrypted password. 3.     The Encryption class: (Additionally See UML Class Diagram) a.     Instance Variables                                                i.     Key – Integer...

  • This project will use The Vigenere Cipher to encrypt passwords. Simple letter substitution ciphers are ones...

    This project will use The Vigenere Cipher to encrypt passwords. 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. Create a Java application that uses: decision constructs looping constructs basic operations on an ArrayList of objects...

  • C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (Strin...

    C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method// that return sting representation of Book object. 2-Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title...

  • You are to create a class Appointment.java that will have the following: 5 Instance variables: private...

    You are to create a class Appointment.java that will have the following: 5 Instance variables: private String month private int day private int year private int hour private int minute 1 default constructor public Appointment() 1 non-default constructor that accepts arguments for all instance variables, your constructor must call the setter methods below to set the values of the instance variables public Appointment(String monthPassed, int dayPassed, int yearPassed, int hourPassed, int minutePassed) 5 setter methods (one for each instance variable)...

  • In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in...

    In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...

  • public class Car {    /* four private instance variables*/        private String make;   ...

    public class Car {    /* four private instance variables*/        private String make;        private String model;        private int mileage ;        private int year;        //        /* four argument constructor for the instance variables.*/        public Car(String make) {            super();        }        public Car(String make, String model, int year, int mileage) {        super();        this.make = make;        this.model...

  • Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the...

    Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT