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]
3 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]3 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
A security administrator wants to empty the DNS cache after a suspected attack that may have corrupted the DNS server. The serve
MAVERICK [17]

Answer:

The easiest method to clear a DNS cache is to use either the command line, PowerShell or Windows Server's DNS Manager

Explanation:

You can use either the ipconfig /flushdns (command line), Clear-DnsClientCache (PowerShell) or DNS->(name)->Clear Cache (from the DNS Manager)

source:

https://activedirectorypro.com/clear-windows-dns-cache/

https://www.technipages.com/flush-and-reset-the-dns-resolver-cache-using-ipconfig

8 0
3 years ago
Read 2 more answers
What is heaven backwards?
sweet-ann [11.9K]
It is Nevaeh backwards hope that helps! :3 and feel free to pm me if you have anymore questions! :3
5 0
3 years ago
Read 2 more answers
In cell B7, enter a formula without using a function to determine the profit generated at the Downtown location by subtracting t
Archy [21]

Answer & Explanation:

The formula in the cell B7 would be:

"=B5-B6"

And now we will press "Ctrl+C" to copy the formula in the Cell B7. After copying we will select the cell range C7 to D7 and press "Ctrl+V" to paste this formula in the cell C7:D7 and then will press Enter key. Now what we see is results in C7:D7 which we can check in our calculator whether these are corectly calculated or not.

3 0
3 years ago
When you schedule an appointment, Outlook adds the appointment to the ____ folder by default.
fomenos
C. schedule.

Outlook adds your appointment to your schedule folder.
6 0
2 years ago
Which blog had legal content and is written mostly by lawyers
Svetradugi [14.3K]
Is it asking for a web site like .edu? or something like that?
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of these statements best describes an application programming interface?
    5·1 answer
  • Write a client program that writes a struct with a privateFIFO name (call it FIFO_XXXX, where XXXX is the pid that you got from
    11·1 answer
  • John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows his to access
    5·1 answer
  • Name an analog quantity other than temperature and sound
    13·1 answer
  • What is a single-user computer?
    8·1 answer
  • What is a header row?
    8·1 answer
  • What does command do
    5·1 answer
  • How to transfer word 2019 from one computer to another
    12·1 answer
  • A company is completing research and development for software which it is planning to produce in approximately 2 years time. Whi
    7·1 answer
  • What refers to the processing of a substance or an object so that it may be used again?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!