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
Lorico [155]
3 years ago
13

Write the definition of a class Counter containing: An instance variable named counter of type int. An instance variable named c

ounterID of type int. A static int variable nCounters which is initialized to zero. A constructor that takes an int argument and assigns its value to counter. It also adds one to the static variable nCounters and assigns the result to the instance variable counterID. A method named increment. It does not take parameters or return a value; it just adds one to the instance variable counter. A method named decrement that also doesn't take parameters or return a value; it just subtracts one from the counter. A method named getValue. It returns the value of the instance variable counter. A method named getCounterID: it returns the value of the instance variable counterID.
Computers and Technology
1 answer:
polet [3.4K]3 years ago
4 0
<h2>The definition of a class Counter </h2>

class Counter

{  

Private :                        //access modifier

int counter;                  //defining and initialising variables

int counterID;

static int nCounters=0;

Public :                               //access modifier

Counter(int a)                     //defining functions

{

counter=a;                 //initialising variable counter with argument a          

nCounters++;                   //incrementing 1 to variable nCounters

}

void increment()

{

counter=counter + 1;

}

void decrement()

{

counter=counter - 1;

}

int getValue()

{

return counter;          //returning integer value contained in counter

}

int getCounterID()

{

return counterID;     //returning integer value contained in counter


}

};       //class definition ends





You might be interested in
The clerk ordered three ribbons, 12 markers, and 15 erasers.
Arada [10]

17 is in all okay my friend

8 0
3 years ago
If the ____________ is broken on a laptop, chances are other parts are also broken.
ella [17]
Central processing Unit
8 0
3 years ago
What font is the declaration of independence?
Keith_Richards [23]
I believe it is old English text
4 0
4 years ago
1) what are two functions of a pick or count condition?
viktelen [127]
1.  The best option is C) pick an object at random, and keep track of how many copies of an object are left in a game.
2.   The best option is D) clockwise and counterclockwise.
3.    your 3rd question does not seem to be clear to me.
3 0
3 years ago
Binary is best interpreted by a computer because ​
Nookie1986 [14]
Because it is the back-end programming. It is the basis of all of the other computer languages and allows the computer to function.
8 0
3 years ago
Read 2 more answers
Other questions:
  • What happens when a Boolean expression is evaluated?
    7·1 answer
  • What are the 6 external parts of a computer system
    8·1 answer
  • Word processing programs have different view options that you can use depending on the tasks you’re performing. Which option hel
    11·1 answer
  • Question 16 (2 points) Question 16 Unsaved
    11·1 answer
  • What advantage does having ultraviolet vision give bees?
    10·2 answers
  • Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
    12·1 answer
  • Thegroup of technologies concerned with the capturing, processing and transmissionof information in the digital electronic form
    9·1 answer
  • Explain the differences between apple and android
    14·2 answers
  • Explain how plant reproduction can affect other living things.
    6·2 answers
  • _______ is a very common approach to multisystem authorization.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!