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
Select four programs that make up system software.Select four programs that make up system software.
Alenkasestr [34]

Operating system

Boot code

Device drivers

Utilities

5 0
2 years ago
Sizing handles are used in Microsoft® Word® to _____.
Kamila [148]
<span>Sizing handles are used in Microsoft Word to resize an object.</span>
8 0
3 years ago
A. True
svetlana [45]

Answer : True  

Explanation: Vectors can hold, data of the same type and can automatically expand accordingly and change it’s size. The date stored in vectors should be linear.  

- The syntax for vector is vector<int>v;

- Mostly this is used in C++ as an alternative to arrays  

- If you want to use vector in your program then define it in the header first  i.e.

#include <vector>

- Push back is a function, that is used to insert an element into the vector  

- Pop back removes the element from the vector  


6 0
2 years ago
how do you set up a slide show to play continuously, advancing through all slides without requiring your interaction? A. Click S
Archy [21]

Answer:

B. Click Set Up, Slide Show, and then select the Loop continously until 'Esc' and use timings, if present options.

Explanation:

PowerPoint presentation is a program which was developed by Microsoft. It is a platform which is used to create business presentation or educational presentations, etc.

In order to play the slide show continuously without our interaction, we need to do the following steps :

1. In the powerpoint presentation, we have to click  "Slide Show" tab in the ribbon and then click on the "Set up slide show" on the Set Up bar.

2. The set up slide show dialogue box will pop up. In this we have to  check or tick on the "Loop continuously until 'Esc' " in the "Show Option" and then click 'OK'

3. Now in the "Slides" preview side panel, we have to click the 1st slide , then Press and hold the 'Shift' key and then click the last slide. This selects all the slides.

4. Now, in the transition tab, in the "Timing" group, we have or uncheck or untick the " On Mouse Click " and also check the " After"

6 0
2 years ago
explain the joke, “There are 10 types of people in the world: those who understand binary and those who don’t.”
tino4ka555 [31]

Answer:

Binary is made up of only 2 digits: a one and a zero. 1011 is eleven in our counting system.

So 10 in binary = 2 in our counting system.

Read the joke as follows. There are 2 types of people in the world: those who  understand binary and those who do not.

I guess it's not really that funny, but computer programmers like it.

6 0
8 months ago
Other questions:
  • Jannette has been experiencing slow performance on her computer. Today she received an error message saying that an update to he
    12·2 answers
  • I don't know the answer and I tried different ones and they not what the book is looking for.
    7·1 answer
  • Tweaking existing technology in a new way is usually called _____. leveraged creativity state-of-the-art breakthrough applicatio
    5·1 answer
  • To display the Color gallery, with the graphic selected, click the Color button in the ____ group on the PICTURE TOOLS FORMAT ta
    14·1 answer
  • Benching system are prohibited in
    5·1 answer
  • For what purpose is keylogging software used? a. To automatically translate input to another language as the user enters data b.
    10·1 answer
  • Question 1 of 20 Gus has decided to organize his inbox on June 26 by using folders and deleting irrelevant messages. He creates
    14·2 answers
  • Which of these is not the correct method for moving text in a document in Word 2016?
    5·1 answer
  • besides entering a url to go directly to a website, what else can you enter in a browser address bar to explore the internet?
    10·1 answer
  • Try using the index method yourself now! Using the index method, find out the position of "x" in "supercalifragilisticexpialidoc
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!