Question: Java: Please help me modify the following code according to the instructions. Thank you. Instructions: User Class Subclass of Account class. Instance variables username String

Java: Please help me modify the following code according to the instructions. Thank you.

Instructions:

  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

Code:

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

/** * Constructor to initialize the variables. * */ public User() { super("", ""); setUsername(""); setFullName(""); setDeptCode(0); }

/** * Constructor to set the variables to the input information. */ public User(String newUsername, String newFullName, int newDeptCode, String newClearPassword, String newKey) { super(newClearPassword, newKey); setUsername(newUsername); setFullName(newFullName); setDeptCode(newDeptCode); }

/** * Method to return the user's username. */ public String getUsername() { return username; }

/** * Method to set the username */ public void setUsername(String newUsername) { username = newUsername; }

/** * Method to return the user's full name. */ public String getFullName() { return fullName; }

/** * Method to set the user's full name */ public void setFullName(String newFullName) { fullName = newFullName; }

/** * Method to return the department code */ public int getDeptCode() { return deptCode; }

/** * Method to set the department code. * */ public void setDeptCode(int newDeptCode) { deptCode = newDeptCode; }

/** * Returns the information for the user. */ public String toString() { String info; info = String.format("%-5s %s %d ", getUsername(), getFullName(), getDeptCode()); info += super.toString(); return info; //(getUsername() + " " + getFullName() + " " + getDeptCode() + "" + super.toString()); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!