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
Lemur [1.5K]
3 years ago
7

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

Computers and Technology
1 answer:
Paraphin [41]3 years ago
6 0

Answer:

I used C++ to implement this program using dev c++, however, i defined the public method inside the class. The code with illustration of this question is given in section phase. If you want to define the classes outside from class then you can use scope resolution operator to access the method of the class. However, the complete running code is given below in <em>explanation </em>section

Explanation:

#include <iostream>// included preprocessor directive

using namespace std;

class player// class player is started from here

{

private:// class varaibles are set at here and scope of varialbe is private.

 string name;//variable for getting and setting name of player

 int score;//variable for getting and setting score of player

 

public:// declaring public method that can be accessbile outside of class but in this program

 void setName (string name)// public method for setting name of player

{

 this->name=name;// name is initialized by paramenter name to variable name

}

 void setScore(int score)//publice method for setting score of player

{

 this->score=score;

}

int getScore()// public method for getting score of player

{

 return score;// on call, return the score of player

}

string getName()// public method for getting name of player

{

 return name;// return player name;

}

 

};//end of class "player"

int main()//main function get executed

{

   player firstPlayer;//class object "firstPlayer" is created

firstPlayer.setName("Renaldo");// firstPlayer name is initialized

firstPlayer.setScore(500);// assgined score to firstPlayer

string getname=firstPlayer.getName();// get name of firstPlayer

int getscore=firstPlayer.getScore();//get score of firstPlayer

cout<<getname;//print name of firstPlayer

cout<<"\n";//line break

cout<<getscore;//print score of firstPlayer

cout<<"\n";//line break

   

   return 0;//end of program

}

You might be interested in
What is the approximate time and death in Sherlock Holmes
kati45 [8]

Answer: 8:58.5204 o'clock a.m

:)

3 0
3 years ago
Read 2 more answers
I need help with completing this python code.Complete the Car class by creating an attribute purchase_price (type int) and the m
netineya [11]

Answer:

class Car:

   def __init__(self):

       self.model_year = 0

       # TODO: Declare purchase_price attribute

       self.purchase_price = 0

       self.current_value = 0

   def calc_current_value(self, current_year):

       depreciation_rate = 0.15

       # Car depreciation formula

       car_age = current_year - self.model_year

       self.current_value = round(self.purchase_price * (1 - depreciation_rate) ** car_age)

# TODO: Define print_info() method to output model_year, purchase_price, and current_value

   def print_info(self):

       print("Model year: ",self.model_year)

       print("Purchase year: ",self.purchase_price)

       print("Current value: ",self.current_value)

def main():

   year = int(input())

   price = int(input())

   current_year = int(input())

   my_car = Car()

   my_car.model_year = year

   my_car.purchase_price = price

   my_car.calc_current_value(current_year)

   my_car.print_info()

if __name__ == "__main__":

   main()

Explanation:

The Car class in the python program is used to create a car object instance with class methods model_year, purchase_price, and calc_current_value, which accepts as arguments, year, price and current_year respectively. The main function runs if only the python module is run and interpreted to print out the year and current price of a car object instance defined.

4 0
3 years ago
You just bought a new hard drive for your computer. You plan to use this as a secondary hard drive to store all your UMA files.
Neko [114]
When you get it you need to make Shure the computer knows you have it
4 0
3 years ago
Which of the following is NOT a cost typically associated with owning a car?
Arturiano [62]
A. fuel ; when you but a car you aren't buying the gas to go in it 
3 0
4 years ago
When installing a SATA hard drive, is it true or false that you need to move the jumpers on the back of the drive to instruct th
antiseptic1488 [7]

Answer:

This is false.

Explanation:

SATA drives do not have jumpers, because they don't use the master/slave feature. They are connected to the motherboard, and they are ready to work.

The master/slave feature was used by IDE hard drives.15 years ago, most motherboards didn't have too many IDE slots to place more than 1 or 2 HDDs, the IDE cable allowed you to connect 2 drives to 1 cable, greatly increasing your computer's storage space.

It was recommended to set as master the drive connected directly to the motherboard, and the other one as slave.

7 0
3 years ago
Other questions:
  • The process of adding a header to the data inherited from the layer above is called what option below
    8·1 answer
  • You are installing several servers that will be used as web servers to reach customers over the Internet. Where should you place
    14·1 answer
  • Rule- based systems are subset of expert systems true or false?
    7·1 answer
  • Why would Network Systems employees be employed by the government?
    12·2 answers
  • QUESTION 9 of 10: Bob charged $200 for a plane ticket last month. When he received his statement, he saw that he could pay the m
    12·2 answers
  • To print the last element in the array named ar, you can write :A. System.out.println(ar.length);
    13·1 answer
  • The NVCC college professor receives frequent emails disguised as official business emails. They may be requests to reset a passw
    10·2 answers
  • Which areas of a business would most benefit from using the Workday platform?
    7·1 answer
  • Vkq-jnfi-uif se-x fun girls joi-n mee-t usin-g this cod_e​
    6·1 answer
  • You have been working as a junior data analyst at Bowling Green Business Intelligence for nearly a year. Your supervisor, Kate,
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!