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

Given 20 March 2018 A class named DOLLS stores a private int variable Ndolls (nu

ID: 3733793 • Letter: G

Question

Given 20 March 2018 A class named DOLLS stores a private int variable Ndolls (number of dolls in stock) float variable Price. The default constructor initializes Ndolls to 100, and Price to $27.95. There are two public member functions: anda . void Order int count), which reduces the number of dolls by count only if at least count int InStockO. which returns the number of dolls in stock dolls are available. 1. Write the code for class DOLLs class DOLLS private: Ndolls float Price public: Void Order (int count int In Stoc k) J: //class DOLLS

Explanation / Answer

// DOLLS class

class DOLLS

{

private:

// private variables

int Ndolls;

float price;

public:

DOLLS()

{

Ndolls = 100;

price = 27.95

}

void Order(int count)

{

// if atleast count dolls are present

if(Ndolls > count)

{

// reduce number of dolld by count

Ndolls = Ndolls - count;

}

}

int InStock()

{

return Ndolls

}

};// class DOLLS

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote