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
You csn access various sites on the www by using hyperlinks or by
Juliette [100K]
You can access sites else by ip address.
6 0
3 years ago
Which invention replaced vacuum tubes in computers?
dlinn [17]

Answer:

Transistors

Explanation:

6 0
3 years ago
In one sentence, how would you sum up the internet?
Slav-nsk [51]

Answer:

an informational system

Explanation:

6 0
3 years ago
Read 2 more answers
During the design phase, development teams translate the requirements into?
Ludmilka [50]
A design for the software application
7 0
3 years ago
Which of the following is FALSE? Select one: a. The fast-paced and collaboration-based business environment makes email less use
12345 [234]

Answer:

The Atos case demonstrates that it is possible to cut out e-mail entirely.

Explanation:

6 0
3 years ago
Other questions:
  • In gaming, "rendering" refers to:
    12·2 answers
  • To ease giving access to network resources for employees, you decide there must be an easier way than granting users individual
    9·1 answer
  • Which of the following statements is true?
    9·1 answer
  • What is the encryption cipher that was the precursor to des??
    5·1 answer
  • Is the jane austen pride and prejudie a primary source
    6·1 answer
  • Data is best described as
    10·2 answers
  • I need help thanks please!
    8·2 answers
  • Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout &lt;&lt; fixed
    7·1 answer
  • Naseer has inserted an image into his document but needs the image to appear on its own line.
    8·1 answer
  • write an algorithm to settle the following question: a bank account starts out with $10,000. interest is compounded monthly at 6
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!