Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEED IT ASAP 1. (13 points) Write a full class definition for a class named Play

ID: 3703751 • Letter: N

Question

NEED IT ASAP

1. (13 points) Write a full class definition for a class named Player, and containing the following members. Member functions will be defined outside the class. . A data member name of type string. A data member score of tvpe int. . A member function called setName that accepts a parameter and assiens it to name. The function returns no value. . A member function called setScore that accepts a parameter and assins it to score. The returns no value . A member function called getName that accepts . A member function called getscor no parameters and returns the value of name. e that accepts no parameters and returns he value of score. (13 points) For the following class with two data members; a. write 2. default constructor and two overload constructors with one and two input parameters. ite code segment in the main section that creates salesl object with default parameters, sales1 object with one parameter, and sales3 object with two parameters. b. Wr Class Sales private: double productPrice; string productName;

Explanation / Answer

1.

#include <iostream>
using namespace std;

class Player
{
private:
string name;
int score;

public:
void setName(string name);
void setScore(int score);
string getName();
int getScore();


};

void Player::setName(string name)
{
this->name = name;
}
void Player::setScore(int score)
{
  this->score = score;
}
string Player::getName()
{
  return name;
}
int Player::getScore()
{
  return score;
}

2.

#include <iostream>
using namespace std;

class Sales
{
private:
double productPrice;
string productName;

public:
Sales()
{
  productPrice = 0.0;
  productName = " ";
}
Sales(string productName)
{
  this->productName = productName;
  this->productPrice = 0.0;
}
Sales(string productName,double productPrice)
{
  this->productName = productName;
  this->productPrice = productPrice;
}
string getProductName()
{
  return productName;
}
double getProductPrice()
{
  return productPrice;
}

};


int main() {

Sales s;
cout<<"Product Name :"<<s.getProductName()<<" Product Price: $"<<s.getProductPrice();

Sales s1("Monitor");
cout<<" Product Name :"<<s1.getProductName()<<" Product Price: $"<<s1.getProductPrice();

Sales s2("CPU",3500.50);
cout<<" Product Name :"<<s2.getProductName()<<" Product Price: $"<<s2.getProductPrice();


return 0;
}

Output:

Product Name :   Product Price: $0
Product Name :Monitor Product Price: $0
Product Name :CPU Product Price: $3500.5

Do ask if any doubt. Please upvote.