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
postnew [5]
4 years ago
9

Write a full class definition for a class named Counter, and containing the following members:________

Computers and Technology
1 answer:
kipiarov [429]4 years ago
3 0

Answer:

The class definition for above problem in java is as follows:-

Explanation:

class Counter // class counter

{

  int counter; // variable counter

  Counter(int v) // construtor

  {

      counter=v;

  }

  void increment() //increment function

  {

      counter=counter+1;

  }

  void decrement() //decrement function

  {

      counter=counter-1;

  }

  int getValue() //getvalue function

  {

      return counter;

  }

}

Code Explanation:

  • The above class definition is in java language.
  • In this code, the name of the class is a Counter and it holds the three functions (increment, decrement and getvalue) and one constructor which is mentioned in the question.
  • To call the above class and their function firstly the user needs to create an object of the counter class in the main function by passing the one integer value on it.
  • The object declaration statement calls the constructor.
  • And then any function can be called by the object of the class with the help of the dot operator.
You might be interested in
A friend a just opened his own barber shop and has asked you to develop a program to track the type of service the customer is r
True [87]

Answer:

class Barber(object):

   barber_shop = "Big AI's barber shop"

   def __init__(self, customer_name, type_of_service=[], tip=0):

       self.cust_name = customer_name

       self.tos = type_of_service

       self.tip = tip

   def service_type(self, *args):

       for i in args:

           self.tos.append(i)

   def total(self):

       

       services = {'trimming':10, 'hair_cut':20, 'shaving':15, 'washing':5, 'dyeing':5}

       contain = ''

       total = 0

       for service in self.tos:

           if service in services.keys():

               total += services[service]

               contain += f'{service}: {services[service]}\n'

       

       print(self.barber_shop,'\n', self.cust_name,'\n', 'Services:',contain.splitlines(),'\n', \

           f'total: ${total}', '\n',f'Tip: ${self.tip}')

mycust = Barber('John',['washing'],6 )

mycust.service_type('shaving', 'dyeing')

mycust.total()

Explanation:

The Barber class is a blueprint used to create an object instance of customers that visits the barber-shop. It has two methods 'service_type' and 'total' which are just defined functions of the class that appends services to the type of service variable and total that prints the total cost of services on the screen.

4 0
3 years ago
Name 3 coding languages
Pavlova-9 [17]

Answer:

javascript, python, c#

Explanation:

7 0
3 years ago
Read 2 more answers
5. Something that has a value 2 points<br>is called a/an<br>O<br>NODE<br>POWER<br>O<br>ATOM​
morpeh [17]

Answer:

it's ONPOA

Explanation:

try use a board game by some of the pins or any type that is part of the game and see if that helps out.

6 0
4 years ago
What is one effective way for employees to keep their skill-sets current
natta225 [31]
Is it a multiple choice answer? if so would like to see the answers as there are TONS of effective ways and if i list one it may not be in that list you have if its multiple choice.
3 0
3 years ago
How to download gta5 ​
Kazeer [188]
Buy the game and hit download
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the name of the malware included in CCleaner?
    11·1 answer
  • Technological improvements have allowed people to inhabit a wider variety of places more easily. Please select the best answer f
    6·2 answers
  • Because the data was formatted the same in two inventory files, you decided to combine their contents into one file. Now you wan
    7·1 answer
  • Balance is the design principle that is represented when using the Crop tool?
    6·1 answer
  • Which of the following is an open-source web browser?
    8·2 answers
  • On the Loan worksheet in cell c9 enter PMT function to calculate the monthly payment for the Altamonte springs 2018 facilities l
    11·1 answer
  • Â A number of companies and/or agencies, such as National ____ and Atmospheric Administrationâs National Weather Service, provid
    9·1 answer
  • Florida law requires every child blank years of age or younger use a crash tested federally be approved child restraint device
    5·2 answers
  • In the scenario below, decide whether you should upgrade the computer or replace it. You’ve been working on your existing laptop
    12·1 answer
  • What is the output of the following code?<br> print (12 // 6)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!