Question

In: Computer Science

When a user signs in for the first time to a website, the user has to...

When a user signs in for the first time to a website, the user has to submit personal information, such as userid, name, email address, telephone number and so on. Typically, there are two fields for passwords, requiring the user to enter the password twice, to ensure that the user did not make a typo in the first password field.

Write a class encapsulating user with the following elements:

UserID

Password

Reentered password

Email address

Name

Street Address

City

State

Zip

You will store these values as strings.

Write the following methods in your class:

1. A constructor which will initialize the 9 attributes listed above.

2. Accessor, mutator, toString methods

3. A method returning the number of characters in the userid

4.. A method checking if the two Strings representing the password fields are the same, if they are return true, otherwise false.

Write a test class to create 2 user objects (using your constructor) and test all the methods in your class.

Solutions

Expert Solution


class User
{
//Attributes
String userID, password, renteredPassword, email, name, streetAddress, city,
    state, zip;
// Contructor
public User ()
{
    this.userID = "";
    this.password = "";
    this.renteredPassword = "";
    this.email = "";
    this.name = "";
    this.streetAddress = "";
    this.city = "";
    this.state = "";
    this.zip = "";
}

// Accessor and Mutators
public String getUserID ()
{
    return this.userID;
}
public void setUserID (String _userID)
{
    this.userID = _userID;
}
public String getPassword ()
{
    return this.password;
}
public void setPassword (String _password)
{
    this.password = _password;
}
public String getRenteredPassword ()
{
    return this.renteredPassword;
}
public void setRenteredPassword (String _renteredPassword)
{
    this.renteredPassword = _renteredPassword;
}

public String getEmail ()
{
    return this.email;
}
public void setEmail (String _email)
{
    this.email = _email;
}
public String getName ()
{
    return this.name;
}
public void setName (String _name)
{
    this.name = _name;
}
public String getStreetAddress ()
{
    return this.streetAddress;
}
public void setStreetAddress (String _streetAddress)
{
    this.streetAddress = _streetAddress;
}
public String getCity ()
{
    return this.city;
}
public void setCity (String _city)
{
    this.city = _city;
}
public String getState ()
{
    return this.state;
}
public void setState (String _state)
{
    this.state = _state;
}
public String getZip ()
{
    return this.zip;
}
public void setZip (String _zip)
{
    this.zip = _zip;
}
//   A Function to find UserID length
public int getUserIDLength ()
{
    return this.userID.length ();
}
//   Function to comapre passwords
public boolean comparePassword ()
{
    return this.password == this.renteredPassword;
}

}

public class Main
{
public static void main (String[]args)
{
    User newUser = new User ();
    // Mutators
      newUser.setUserID ("atriax");
      newUser.setPassword ("mypass");
      newUser.setRenteredPassword ("mypass");
      newUser.setEmail ("[email protected]");
      newUser.setName ("Atriax Gethon");
      newUser.setCity ("New York");
      newUser.setState ("Washington DC");
      newUser.setZip ("124332");
      newUser.setStreetAddress ("221 B,Bakers Street");
    // Print the Details
      System.out.println ("User ID: " + newUser.getUserID ());
    // chehck User ID length
      System.out.println ("User ID Length: " + newUser.getUserIDLength ());
    // Compare the passwords
      System.out.println ("Passwords Match: " +
              newUser.comparePassword ());
      System.out.println ("Email: " + newUser.getEmail ());
      System.out.println ("Street Address: " + newUser.getStreetAddress ());
      System.out.println ("City: " + newUser.getCity ());
      System.out.println ("State: " + newUser.getState ());
      System.out.println ("Zip: " + newUser.getZip ());


}
}


Related Solutions

When a user signs in for the first time to a website, the user must submit...
When a user signs in for the first time to a website, the user must submit personal information, such as last name, first name, email address, and so on. Typically, there are two fields for passwords, requiring the user to enter the password twice, to ensure that the user did not make a typo in the first password field. Write a class encapsulating user with the following attributes: UserID Password Reentered password Email address Last Name First Name Zip You...
Based on a study, the average elapsed time between when a user navigates to a website...
Based on a study, the average elapsed time between when a user navigates to a website on a mobile device until its main content is available was 14.6 seconds. This is more than a 20% increase from the previous year. Responsiveness is certainly an important feature of any website and is perhaps even more important on a mobile device. What other web design factors need to be considered for a mobile device to make it more user friendly? Among other...
A website is trying to increase registration for first-time visitors, exposing 1% of these visitors to...
A website is trying to increase registration for first-time visitors, exposing 1% of these visitors to a new site design. Of 752 randomly sampled visitors over a month who saw the new design, 64 registered. (a) Check any conditions required for constructing a confidence interval. (b) Compute the standard error. (c) Construct and interpret a 90% confidence interval for the fraction of first-time visitors of the site who would register under the new design (assuming stable behaviors by new visitors...
.Code for a game of Tetris in C# .Short explanation for a first time user, showing...
.Code for a game of Tetris in C# .Short explanation for a first time user, showing them how to use it and pointing out all of the pertinent features. (1 paragraph) .Provide a few screen shots if possible
mobile App Website Design. Based on a 2018 study, the average elapsed time between when a...
mobile App Website Design. Based on a 2018 study, the average elapsed time between when a user navigates to a website on a mobile device until its main content is available was 14.6 seconds. This is more than a 20% increase from 2017. Responsiveness is certainly an important feature of any website and is perhaps even more import-ant on a mobile device. What other web design factors need to be considered for a mobile device to make it more user...
Identify one website that is exceptionally user- friendly and another that is not. What are the...
Identify one website that is exceptionally user- friendly and another that is not. What are the factors that make for a satisfying user experience in the first instance and a frustrating one in the second? Specify recommendations for improvements in the second website.
Write a program that: a.Asks the user for their first name.b.Asks the user for their...
Write a program that: a.Asks the user for their first name. b.Asks the user for their age. c.Asks the user for their last name. d.Print out to the user the following information: i.Number of characters in the first & last name combined ii.The full name all in upper case letters iii.The full name all in lower case letters iv.The first letter of the name v.The age Compile and test your code in NetBeans and then on Hackerrank at www.hackerrank.com/csc127-chapter2-classwork then...
The first trimester is a period of great vulnerability and it is often a time when...
The first trimester is a period of great vulnerability and it is often a time when a woman does not even realize she is pregnant. why is this stage so difficult to pass? why wouldn't we be evolutionarily adapted to more successful pregnancies at this point?
According to a social media​ blog, time spent on a certain social networking website has a...
According to a social media​ blog, time spent on a certain social networking website has a mean of 16 minutes per visit. Assume that time spent on the social networking site per visit is normally distributed and that the standard deviation is 5 minutes. Complete parts​ (a) through​ (d) below. a. If you select a random sample 36 sessions, what is the probability that the sample mean is between 15.5 and 16.5 minutes? = 0.452 b. If you select a...
According to a social media​ blog, time spent on a certain social networking website has a...
According to a social media​ blog, time spent on a certain social networking website has a mean of 21 minutes per visit. Assume that time spent on the social networking site per visit is normally distributed and that the standard deviation is 3 minutes. Complete parts​ (a) through​ (d) below. a. If you select a random sample of 16 ​sessions, what is the probability that the sample mean is between 20.5 and 21.5 ​minutes? nothing ​(Round to three decimal places...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT