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
____ [38]
3 years ago
9

Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T

he Counter class should contain a single integer as instance data, representing the count. Write a constructor to initialize the count to zero. Write a method called click that increments the count and another method called get Count that returns the current count. Include a method called reset that resets the counter to zero. Finally, create a driver class called CounterTest that creates two Counter objects and tests their methods.
Computers and Technology
1 answer:
Sonja [21]3 years ago
4 0

Answer:

Code is in java

Explanation:

Code is self explanatory, added come comments to explain more about the code.

public class CounterDriver {

   public static void main(String[] args){

       // Creating counter first object

       Counter counter1 = new Counter();

       //performing 2 clicks

       counter1.click();

       counter1.click();

       // displaying counter 1 click count

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

       // resetting counter 1 click count

       counter1.reset();

       // again displaying click count which will be 0 after reset

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

      // Same operation goes with counter 2  

       // the only difference is that it performs 3 clicks

       Counter counter2 = new Counter();

       counter2.click();

       counter2.click();

       counter2.click();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

       counter2.reset();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

   }

}

class Counter{

   int count;

// defining constructor which will initialize count variable to 0

   public Counter(){

       this.count=0;

   }

// adding click method to increment count whenever it's called

   public void click(){

       this.count++;

   }

// getCount method will return total count

   public int getCount(){

       return this.count;

   }

// reset method will set count to 0

   public void reset(){

       this.count = 0;

   }

}

You might be interested in
List at least three benefits of automated testing?
nlexa [21]

Answer:

Always available to run: You can run the tests 24/7, when you are at work, when you leave the office or if you working remote, you can run the test. They can be run virtually unattended, leaving the results to be monitored towards the end of the process.

Fewer human resources: You can reduce the people advocated on testing, you would need a QA automation to write your scripts to automate your tests, instead of people doing manual tests. In addition, once automated, the test library execution is faster and runs longer than manual testing.

Reusability and reliability: The scripts are reusable, a script could be used hundreds of times before need changes. It allows you to test exactly the same, without forgetting any steps this is why is more reliable and way quicker than manual test where people may cause.  

5 0
3 years ago
What feature preserves your open apps and data, but allows another user to log in to his or her own session of the same computer
Hitman42 [59]

A feature that preserves open apps and data while allowing another user to log in to his or her own session of the same computer is: switch user.

<h3>What is a computer?</h3>

A computer is an electronic device that is designed and developed to receive data from an end user in its raw form (input) and processes these data into an output that could be used for other purposes.

Generally, all computers are designed and developed with a feature called switch user, so as to preserve open software applications and data while allowing another user to log in to his or her own session of the same computer simultaneously.

Read more on computer here: brainly.com/question/959479

6 0
1 year ago
CLS <br> N = 1<br> FOR J = 1 TO 5 <br> PRINT N<br> N = 10*N+1 <br> NEXT J<br> END
Lemur [1.5K]

Answer:

1

11

111

1111

11111

Explanation:

Given

The above QBasic code

Required

The output

The iteration on the third line is repeated 5 times; i.e. for values of j from 1 to 5.

In each iteration, the value of N is printed and the next value is calculated.

Initially, the value of N is 1 ---- on line 2

So, 1 is printed first. The next value of N is as follows:

N = 10 * N + 1 --- we keep replacing N (on the right-hand side) with current N value.

So, we have:

N = 10 * 1 + 1 =11

N = 10 * 11 + 1 = 111

N =10 *111+1 = 1111

N =10 *1111+1 = 11111

4 0
3 years ago
A field with the extend data type can contain an attached file, such as an image, document, chart, or spreadsheet.
enyata [817]
The attachment data type can contain an attached file such as image document chart or spreadsheet. hope I helped
8 0
2 years ago
A type of authentication that requires the user to provide something that they know, such
bagirrra123 [75]
The answer would be true
5 0
3 years ago
Other questions:
  • What is the oldest and most common technique to differentiate information systems?
    8·1 answer
  • (01.03 LC)
    9·1 answer
  • A network administrator for a small company is contemplating how to scale the network over the next three years to accommodate p
    13·1 answer
  • What's the best strategy for avoiding ATM fe
    14·1 answer
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • "The ability to assign system policies, deploy software, and assign permissions and rights to users of network resources in a ce
    7·1 answer
  • Match each career to its various job roles. digital media coordinator digital media specialist photographer sound producer creat
    13·1 answer
  • The East Coast sales division of a company generates 62 percent of total sales. Based on that percentage, write a Python program
    7·1 answer
  • In your own words, what is Cryptocurrency?
    15·2 answers
  • Choose the answer.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!