1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alexxandr [17]
2 years ago
5

This question involves the implementation of the PasswordGenerator class, which generates strings containing initial passwords f

or online accounts. The PasswordGenerator class supports the following functions:
- Creating a password consisting of a specified prefix, a period, and a randomly generated numeric portion of specified length
- Creating a password consisting of the default prefix "A", a period, and a randomly generated numeric portion of specified length
- Reporting how many passwords have been generated

The following table contains a sample code execution sequence and the corresponding results: Statements, Possible Value Returned (blank if no value returned), Comment

PasswordGenerator pw1 = new
PasswordGenerator(4, "chs");
(blank)
Passwords generated by the pw1 object are composed of the prefix "chs", a period, and 4 randomly-generated digits.
pw1.pwCount();
0
No passwords have been generated yet.
pw1.pwGen();
"chs.3900"
A possible password generated by the pw1 object
pw1.pwGen();
"chs.1132"
A possible password generated by the pw2 object
pw1.pwCount();
2
Two passwords have been generated. Both contain the prefix "chs" and 4 digits.
PasswordGenerator pw2 = new
PasswordGenerator(6);

Passwords generated by the pw2 object are composed of the default prefix "A", a period, and 6 randomly generated digits.
pw2.pwCount();
2
Two passwords have been generated. Both contain the prefix "chs" and 4 digits.
pw2.pwGen();
"A.843055"
A possible password generated by the pw2 object
pw2.pwCount();
3
Three passwords have been generated. Two contain the prefix "chs" and 4 digits, and the third contains the default prefix "A" and 6 digits.
pw1.pwCount();
3
Three passwords have been generated. The same value is returned by pwCount for all objects of the PasswordGenerator class.

Write the complete PasswordGenerator class. Your implementation must meet all specifications and conform to the example.
Computers and Technology
1 answer:
liq [111]2 years ago
8 0

The following code will be used for the PasswordGenerator class.

<u>Explanation:</u>

import java.util.Random;

public class PasswordGenerator {

   private static int passwordsGenerated =0;

   private static Random random = new Random();

   private String prefix;

   private int length;

   public PasswordGenerator(int length,String prefix) {

       this.prefix = prefix;

       this.length = length;

   }

   public PasswordGenerator(int length) {

       this.prefix = "A";

       this.length = length;

   }

   public String pwGen(){

       String pwd= this.prefix+".";

       for(int i=1;i<=this.length;i++){

           pwd+=random.nextInt(10);

       }

       passwordsGenerated+=1;

       return pwd;

   }

   public int pwCount(){

       return passwordsGenerated;

   }

   public static void main(String[] args) {

       PasswordGenerator pw1 = new PasswordGenerator(4,"chs");

       System.out.println(pw1.pwCount());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwCount());

       PasswordGenerator pw2 = new PasswordGenerator(6);

       System.out.println(pw2.pwCount());

       System.out.println(pw2.pwGen());

       System.out.println(pw2.pwCount());

       System.out.println(pw1.pwCount());

   }

}

You might be interested in
Apple Final Cut Pro is a digital video editing program that is available for Macs with OS X version 10.4 or later.
aniked [119]
That's actually true lol

3 0
3 years ago
Read 2 more answers
What is the full form of PDP​
PtichkaEL [24]

Answer:

<em>Plasma display panel </em>(PDP)

Explanation:

<em>Plasma display panel </em>(PDP) is a type of flat panel display that uses small cells containing electrically charged ionized gases or plasmas, to produce an image. PDP consists of millions of tiny gas-filled compartments, or cells, between two panels of glass with parallel electrodes deposited on their surfaces.

3 0
3 years ago
a ____ is a duplicate of a file, program, or disk that you can use in case the original is lost, damaged, or destroyed.
AleksAgata [21]
A backup is a duplicate of the file, program or disk that you can use in case the original is lost, damaged or destroyed.
3 0
3 years ago
!PLEASE HELP! My business office specialist class, this is about Access.
Over [174]

Answer:

b

Explanation:

6 0
2 years ago
Read 2 more answers
By dividing the control plane from the data plane, SDN offers the flexibility to view the entire data plane infrastructure as a
Mariulka [41]

Answer:

Virtual

By dividing the control plane from the data plane, SDN offers the flexibility to view the entire data plane infrastructure as a Virtual resource that can be configured and controlled by an upper layer control plane.

Explanation:

The separating data plane (SDN) is used by users to hide the specifics of a device data layer so that all devices would be treated equally thereby representing the entire data plane as a  virtual abstract layer thus enhancing network efficiency.

The SDN work mainly on the Control and data plane separating both of the planes. Also, the SDN make networks more agile and flexible.

SDN provides the flexibility to view the entire data plane infrastructure as a

virtual resource that can be configured and controlled by an upper layer

control plane.

6 0
2 years ago
Read 2 more answers
Other questions:
  • Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author'
    14·1 answer
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    12·1 answer
  • Students are studying the effects of beach pollution by counting populations of seagulls at two different beach locations. One l
    7·1 answer
  • You have just installed a new sound card in your system, and Windows says the card installed with no errors. When you plug up th
    5·1 answer
  • Which options are available when a user modifies a recurring appointment? Check all that apply. Open this occurrence Open the fi
    12·2 answers
  • What service converts ip addresses into more recognizable alphanumeric names??
    8·1 answer
  • The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi
    6·1 answer
  • DDL statement for adding a column to an existing table is
    15·1 answer
  • How can the two independent clauses below be combined to form a correct complete sentence? Check all that apply.
    5·1 answer
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!