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
You receive an offer for a credit card that can be use to accrue points that
Jlenok [28]

Answer: (C) A special service for current customers

Explanation:

  The CRM is the customer relationship management that typically use by the banks for providing special type of services to the current customer. This is the way to attract various types of users or customers by providing some special type of offers.

According to the question, bank provide the credit card offers to the customer on the airline tickets so, it is beneficial for both the customer and for the bank as well.

3 0
3 years ago
What Two external audio recorders are most commonly used ??
zimovet [89]

Answer:

Very few recorders have built-in microphones that are useful for field reporting. Does the recorder have XLR (professional grade) input, Tip-Ring Sleeve (TRS) input or just a mini jack? Format – There are two types of audio files: compressed and uncompressed. Cheap audio recorders will compress all of the audio it captures.

Explanation:

hope this helps mark as brainiest.

3 0
3 years ago
Network a0 is a process by which several protocols evolve to form a single product.
mafiozo [28]

Answer:

Convergent network

Explanation:

In networking, computers devices are connected together to communicate and share resources. Devices like routers and switches are examples of intermediate network devices and computers, smartphones, tablets and IP phones are all examples of end devices in a network.

In the past, dedicated networks are installed for separate voice, text and video packets. But as information technology evolves, one network is used for all three packets. This network is called convergent network.

6 0
3 years ago
In a linked chain implementation of a stack ADT the performance of popping am emtry from the stack is
Mice21 [21]

Answer:

B.O(1)

Explanation:

When we are implementing ADT stack using linked chain we can pop an entry from the stack having O(1) time complexity because in linked chain we have the head or top pointer in linked chain only.Popping and pushing in stack happens on only one end that is top.So we have move to move top in linked chain to the next and delete prev node.

8 0
3 years ago
Software that people commonly use in the workplace to make their lives easier is called?
emmasim [6.3K]
Answer: System Software

7 0
3 years ago
Other questions:
  • Henry Ford would have been most interested to bring which modern innovation to his automotive factories?
    5·2 answers
  • Create a program in Python that prompts the user to enter an integer number within the range of 1 to 10 inclusive. The program s
    15·2 answers
  • 1. Railroad tracks present no problems for a motorcyclist.
    8·1 answer
  • Tell me the most scariest website you know and i'll give you brainlest
    5·1 answer
  • Please help ASAP!
    15·1 answer
  • Determine whether or not the following pairs of predicates are unifiable. If they are, give the most-general unifier and show th
    13·1 answer
  • Which interpersonal skill is the most important for a telecom technician to develop?
    7·1 answer
  • A merchant bank and a merchant have been involved in a Web-based electronic transaction. Which of the following mediates between
    9·1 answer
  • In NumPy, the_______
    6·1 answer
  • if a user watches a video with event tracking three times in a single session, analytics will count how many unique events?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!