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
Explain the following terms:<br><br> a) Atomicity<br><br> b) DML
GenaCL600 [577]

Answer:

a) Atomicity:- It is among the one of the ACID properties of transactions.It states that an atomic transaction is irreducible and indivisible series of data operations such that either nothing occurs or all occurs.

b) DML(Data Manipulation Language):- It is a computer programming language that is used for inserting,deleting,manipulating data in the database.For example -SQL.

6 0
3 years ago
A program in which students learn a specific skill for a particular job is called a
Ne4ueva [31]
A certification program.
7 0
3 years ago
Read 2 more answers
comparative clinical and cost analysis between surgical and non-surgical intervention for knee osteoarthritiis
solmaris [256]

To assess the treatment options and costs for osteoarthritis of the knee (OAK), a condition that affects the knee joint and progresses over time owing to cartilage and bone deterioration.

Methods: Over the course of two years, we prospectively examined the clinical results and quantified cumulative direct expenses of patients with OAK sent to our multidisciplinary OA programme.

A total of 133 patients were evaluated. All showed radiographic signs consistent with moderate to severe OAK. We tracked and examined changes in the Western Ontario McMaster Osteoarthritis Index (WOMAC), Minimal Clinically Important Improvement (MCII), and BMI.

The total direct expenditures for all subjects' medical and surgical care during a two-year period were calculated.

Learn more about osteoarthritis:

brainly.com/question/28546590

#SPJ4

5 0
1 year ago
You are the network adminstrator for your company your network consists of two active directory domains research.westsim.local a
nexus9112 [7]

Answer:

We should configure the one of domain controller in the Houston to be the global catalog servers.

Explanation:

Configure the Domain controller:

1. Log in the MS Windows server host.

2. Then, click the Start Menu and goto the Tools, click on Manage Your Servers.  

  • on this wizard, you can choose the Adding Roles to your Servers.
  • in Server Role windows you can choose the Domain Controller.
  • Then, you can select the default values by the click on NEXT.
  • Then, continue accepts default values and click on the Next when the Report DNA Issues windows appears.
  • Then, select the Configure and install DNS for proceed to next window.
  • Then, continue to click on the Next when the Summary window will display then again click next.
  • After all, Active Directory Installation wizards are invoked.
5 0
3 years ago
What type of major application has most changed the way people interact in their daily lives?
kogti [31]
Social media, Facebook has become really popularized as has youtube and tumblr. Many people communicate through messenger on facebook, videos on youtube and just posting different things on tumblr. The way people put themselves out into the world, and portray who they are to people across the world is huge change from say 20 years ago.
5 0
3 years ago
Other questions:
  • Which is true about POP3 and IMAP for incoming email?
    12·1 answer
  • which computer career field enables you to create and design interactive multimedia products and services
    14·1 answer
  • GDP measures the production levels of any nation. This implies a correlation between production levels and ____________.
    8·1 answer
  • You are asked to monitor a network which has a network monitoring system. Using the monitoring server, you notice that it is lis
    13·1 answer
  • You can use a(n) to call a function in response to an event?
    14·1 answer
  • Whats a hybrid wired network
    9·1 answer
  • Courses that enable students to begin jobs that require course completion certificates are know as
    8·1 answer
  • You want to be able to identify the services running on a set of servers on your network. Which tool would best give you the inf
    11·1 answer
  • If you see these REPORT.
    14·2 answers
  • The U.S. consumes lots of energy. Which fuel provides the most energy?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!