help with Implementing class Item

Pages: 1234
looking for help on this code. most of it is notes of what I need to include. just
unsure of how to start this or if what I have is doable


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <iostream> 
#include <fstream>  
#include <iomanip>
using namespace std;

class Object { // Change name to be your custom-designed class
  private:
    ; // provide at least 4 attributes of different types, including string name
    /*
     Design of class fruit. Essential information about a fruit.
     It has these private data members:
     
     name - string that describes the fruit
     quantity - an int that holds the number of fruit you have
     weight - double to hold the weight of the fruit
     price - a float that holds the price of the fruit
     is_purchased -  a bool, true or false, wheter the fruit is being purchased or not
     */
    string
    apple,
    orange,
    banana,
    avocado,
    grapes;


  public:
    ; // provide 2 constructors (default with no parameters and 2nd with parameters),
setters, getters.
    
    /*
     default constructor: sets all the members to their default values – if in doubt,
use the default initializers
for the values, such as: int amount{}; it is a “default fruit” whatever that is.
     
     
     
constructor #2    The new fruit's name, amount, weight, etc. are arguments.
Calls the individual setters
(below) to validate and set the variable.

     set_name    Accept a string argument and copies it into the name variable
     set_amount    Accepts an int argument and copies it into amount variable, but ONLY if >= 0
     set_weight    Accept a float argument and copies it into the weight variable if valid
     set_price   Accepts a double argument and copies it into the price, if reasonable
     
     
     Retrieval of data is done with getters:

     Member Function/Method    Description 

     get_name    Returns the value in name

     get_amount    Returns the value of rooms

     get_weight    Returns the value of square_feet

     get_prie    Returns the list_price of the house


cout a string to output a full description:

     name: orange, amount:3, weight:7.5, price: $25

     */
    
};


/*
 Provide two constructors: one for a “default” object, and one for an object where all the initial
values are provided. Provide setters that validate new values and changes data members if OK.
Provide getters. One of the getters should be a show / display / print / cout getter that shows all
information about the object.  Another getter should show some combination of data members,
such as: get_price_per_sqft, which performs a calculation and then produces a result:
get_price_per_sqft() returns list_price / square_feet.
 
 
 After the class is working, create at least 5 different, separate instances of the class,
such as: fruit1, fruit2, ... fruit5. Create 3 instances with all valid data and 2
instances with some (attempted) invalid data. .
 (apple, orange, pear, grapes, avocado)
 #      Name        quantity    weight      price        purchased?
        STRING      INT         DOUBLE      FLOAT        BOOL
 1      apple       4           4.56        $4           true
 2      orange      7           2.65        $5           false
 3      banana      4           2.34        $2           true
 4      avocado     150,023     -3.45       $-150000     true
 5      grapes      -3          -1000       $-10000      false
 
 
 Setters should NOT change existing valid member values to invalid values.
If given invalid data in a setter, reject it. Do not change the value.
 
 Modify the program to ask: "How many objects do you want?". Loop as many times
specified by the user (5 is enough for testing) to create that many objects.
You can use 5 individual variables, or you can use an array or vector.
Submit one .cpp file. Do not create the class in a separate file.
 
 */


int main() {
  cout << "This program creates at least 5 separate, co-existing instances of a "
          "custom designed object.\nInformation about each object is displayed.\n"
          "Each constructor, setter and getter is tested at least once.\n";

  // Test code goes here. Construct objects with valid and invalid data.
  // Verify that each constructor, setter and getter was executed at least once.

  cout << "\nThis ends the class design, implementation, test program. Goodbye.\n";
    return EXIT_SUCCESS;
}   // end of main


// desired output below:
the information should match what I have on L75-L81
/*
 You created 5 objects:
 # 1 of 5 objects:
  name: pokemon game;  ID: 1111;  quantity: 10;  cost: $52.25;  total cost: $522.50

 # 2 of 5 objects:
  name: apple cart;  ID: 2222;  quantity: 5;  cost: $25.00;  total cost: $125.00

 # 3 of 5 objects:
  name: umbrella;  ID: 3333;  quantity: 100;  cost: $25.00;  total cost: $2500.00

 # 4 of 5 objects:
  name: tennis shoes;  ID: 4444;  quantity: 100;  cost: $8.99;  total cost: $899.00

 # 5 of 5 objects:
  name: hockey pucks;  ID: 5555;  quantity: 50;  cost: $5.11;  total cost: $255.50
*/

Last edited on
unsure of how to start this or if what I have is doable
That depends on what you're trying to do.
The first step should be very straightforward - simply define the class data members that you've been told to define.

Also, what is the purpose of the following data members?

1
2
3
4
5
6
    string
    apple,
    orange,
    banana,
    avocado,
    grapes;

well the instructions say "provide at least 4 attributes of different types"

as stated I have these

name - string that describes the fruit
quantity - an int that holds the number of fruit you have
weight - double to hold the weight of the fruit
price - a float that holds the price of the fruit
is_purchased - a bool, true or false, wheter the fruit is being purchased or not

how do I incorporate that?
Last edited on
You clearly already know how to define class data members, because you've already declared five of them.

Also, you haven't answered my question. There's little point any of us replying to you, if you're not even going to engage with what we write.
well I'm using "class Fruit" for this project the purpose of those strings is just to name out 5 different fruits that will then be printed out with the data I have from L75-L81.

I'm not sure how to correctly define the class data members. do I just list them out how I had it or is that the incorrect way to do it?

1
2
3
4
5
6
7
8
9
class Fruit {
  private:
    string 
    int 
    double
    float
    bool
public:
.....
They'll need to have names, obviously.

But you already know this, because you've already defined some in the code you've posted.

Why do you need 5 different data members for the names of the fruits? Wouldn't each Fruit object only need to store one string - its own name?
should it look like this instead? and then just create types for every fruit?

1
2
3
4
5
    string name;
    int quantity;
    double weight;
    float price;
    bool is_purchased;
Yes, that looks right to me.

I don't see where you need to create different types. Your instructions just say to create 5 instances of the same type, with different values for the data members.

EDIT: If you're using std::string, you should include the header <string> .
Last edited on
great. I'm working on the constructors now.

// provide 2 constructors (default with no parameters and 2nd with parameters), setters, getters.


I have to set all the members to their default values which I can just set to 0 and the name to default fruit to apple.

I believe I have the string completed, what is the correct way to incorporate the int, double, float, and bool?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public:
    Fruit(string z){
        setName (z);
    }
    void setName(string x){
        name = x;
    }
    string getName(){
        return name;
    }


/*to print out name:
 Fruit bo("Apple");
    cout << bo.getName() << endl;
    */
Last edited on
With quantity. The others are similar:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>

class Fruit {
public:
	Fruit(const std::string& z, unsigned qty) : name(z), quantity(qty) {}
	void setName(const std::string& x) { name = x; }
	auto getName() const {return name; }
	void setQuantity(unsigned q) { quantity = q; }
	auto getQuantity() const { return quantity; }

private:
	std::string name;
	unsigned quantity {};
	double weight {};
	float price {};
	bool is_purchased {};
};

int main() {
	 Fruit bo("Apple", 5);

	 std::cout << bo.getName() << "  " << bo.getQuantity() << '\n';
}

Last edited on
EDIT: int under private has been corrected

does this look correct?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#include <iostream>
#include <string>

class Fruit {
public:
Fruit(const std::string& z, unsigned qty) : name(z), quantity(qty) {}
        void setName(const std::string& x) { name = x; }
        auto getName() const {return name; }
    
        void setQuantity(int q) { quantity = q; }
        auto getQuantity() const { return quantity; }
    
        void setWeight(double w) { weight = w; }
        auto getWeight() const {return weight;}
    
        void setPrice(float p) { price = p; }
        auto getPrice() const {return price;}
    
        void setIs_purchased(bool i) { is_purchased = i; }
        auto getIs_purchased() const {return is_purchased;}

  private:
    string name;
    int quantity;
    double weight;
    float price;
    bool is_purchased;
;

int main() {
	 Fruit bo("Apple", 5);

	 std::cout << bo.getName() << "  " << bo.getQuantity() << '\n';
}


Last edited on
Presumably, your constructor is supposed to take and set all the data members, not just name and quantity?

Also, you haven't written the default constructor.
Line 20, is_purchased has type bool but i has type unsigned int. A similar issue occurs on lines 14 and 17 for price and weight.

Fruit::quantity should have type int. The (mis-)use of unsigned int here will just obscure errors in your program.
could you guys review it one more time. I have updated it above but unsure if that's correct
Last edited on
Still need to address @mikeyboy's post above
Last edited on
If you're having quantity as int (??), then L7 needs changing.

The member variables L25-28 should be initialised as in my post above.

If a default constructor is required, then this needs to be provided (assuming the member variables are initialised):

 
Fruit() {}


The constructor needs to be extended to also include the other values. Based upon L7, this should be easy.....
Last edited on
does this work for the default constructor?
it sets everything to 0 on the first cout..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

#include <iostream> // for cin, cout, endl
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

// provide at least 4 attributes of different types
class Fruit {
  private:
    string name;
    int quantity;
    double weight;
    float price;
    bool is_purchased;
    ;

  public:
    Fruit(const std::string& z, int qty) : name(z), quantity(qty) {}
        void setName(const std::string& x) { name = x; }
        auto getName() const {return name; }
    
        void setQuantity(int q) { quantity = q; }
        auto getQuantity() const { return quantity; }
    
        void setWeight(double w) { weight = w; }
        auto getWeight() const {return weight;}
    
        void setPrice(float p) { price = p; }
        auto getPrice() const {return price;}
    
        void setIs_purchased(bool i) { is_purchased = i; }
        auto getIs_purchased() const {return is_purchased;}
    
    ;
    
    struct Fruit_t{
        int quantity{};
        double weight{};
        float price{};
        bool is_purchased{};
    };
    // provide 2 constructors (default with no parameters and 2nd with parameters),
setters, getters.
    
    /*

    constructor #2    The new fruit's name, amount, weight, etc. are arguments.
Calls the individual setters (below) to validate and set the
    variable.

     set_name    Accept a string argument and copies it into the name variable
     set_amount    Accepts an int argument and copies it into amount variable, but ONLY if >= 0
     set_weight    Accept a float argument and copies it into the weight variable if valid
     set_price   Accepts a double argument and copies it into the price, if reasonable
     
     
     Retrieval of data is done with getters:

     Member Function/Method    Description 

     get_name    Returns the value in name

     get_amount    Returns the value of rooms

     get_weight    Returns the value of square_feet

     get_prie    Returns the list_price of the house


cout a string to output a full description:

     name: orange, amount:3, weight:7.5, price: $25

     */
    
};


/*
 
 
 After the class is working, create at least 5 different, separate instances of the class,
such as: fruit1, fruit2, ... fruit5. Create 3 instances with all valid data and 2 instances
with some (attempted) invalid data. .
 (apple, orange, pear, grapes, avocado)
 #      Name        quantity    weight      price        purchased?
        STRING      INT         DOUBLE      FLOAT        BOOL
 1      apple       4           4.56        $4           true
 2      orange      7           2.65        $5           false
 3      banana      4           2.34        $2           true
 4      avocado     150,023     -3.45       $-150000     true
 5      grapes      -3          -1000       $-10000      false
 
 
 Setters should NOT change existing valid member values to invalid values.
If given invalid data in a setter, reject it. Do not change the value.
 
 Modify the program to ask: "How many objects do you want?".
Loop as many times specified by the user (5 is enough for testing) to
create that many objects. You can use 5 individual variables, or you can
use an array or vector. Submit one .cpp file. Do not create the class in a separate file.
 
 */


int main() {
  cout << "This program creates at least 5 separate, co-existing instances of a\n"
          "custom designed object. Information about each object is displayed.\n"
          "Each constructor, setter and getter is tested at least once.\n";

    
    Fruit::Fruit_t apple, orange, banana, avocado, grapes;
    cout << "name: apple price: " << apple.price
    << " weight: "<<apple.weight
    <<" quantity: "<< apple.quantity
    <<" purchased?: "<< apple.is_purchased<< endl;
    
    apple.price = 4; apple.weight=4.56; apple.quantity=4; apple.is_purchased=true;
    cout << "name: apple price: " << apple.price
    << " weight: "<<apple.weight
    <<" quantity: "<< apple.quantity
    <<" purchased?: "<< apple.is_purchased<< endl;
    
    cout<<endl;
    
    orange.price = 5; orange.weight=2.65; orange.quantity=7; orange.is_purchased=false;
    cout << "name: orange price: " << orange.price
    << " weight: "<<orange.weight
    <<" quantity: "<< orange.quantity
    <<" purchased?: "<< orange.is_purchased<< endl;
    
    
    
    
 //   Fruit bo("Apple", 5);
   //      std::cout << bo.getName() << "  " << bo.getQuantity() << '\n';
    
    
    
    cout << "\nThis ends the class design, implementation, test program. Goodbye.\n";
    return EXIT_SUCCESS;
}   // end of main


Last edited on
Hmmmmmmmm.....

Perhaps something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

class Fruit {
public:
	Fruit() {}
	//Fruit(const std::string& z, int qty, double wgt, float prc, bool isp) : name(z), quantity(qty), weight(wgt), price(prc), is_purchased(isp) {}
	Fruit(const std::string& z, int qty, double wgt, float prc, bool isp) : name(z), is_purchased(isp) {
		setQuantity(qty), setWeight(wgt), setPrice(prc);
	}

	void setName(const std::string& x) { name = x; }
	auto getName() const { return name; }

	void setQuantity(int q) { if (q >= 0) quantity = q; }
	auto getQuantity() const { return quantity; }

	void setWeight(double w) { if (w > 0) weight = w; }
	auto getWeight() const { return weight; }

	void setPrice(float p) { if (p >= 0) price = p; }
	auto getPrice() const { return price; }

	void setIs_purchased(bool i) { is_purchased = i; }
	auto getIs_purchased() const { return is_purchased; }

private:
	string name;
	int quantity {};
	double weight {};
	float price {};
	bool is_purchased {};
};


/*
 After the class is working, create at least 5 different, separate instances of the class,
such as: fruit1, fruit2, ... fruit5. Create 3 instances with all valid data and 2 instances
with some (attempted) invalid data. .
 (apple, orange, pear, grapes, avocado)
 #      Name        quantity    weight      price        purchased?
		STRING      INT         DOUBLE      FLOAT        BOOL
 1      apple       4           4.56        $4           true
 2      orange      7           2.65        $5           false
 3      banana      4           2.34        $2           true
 4      avocado     150,023     -3.45       $-150000     true
 5      grapes      -3          -1000       $-10000      false


 Setters should NOT change existing valid member values to invalid values.
If given invalid data in a setter, reject it. Do not change the value.
*/

int main() {
	Fruit apple("apple", 4, 4.56, 4, true),
		orange("orange", 7, 2.65, 5, false),
		banana("banana", 4, 2.34, 2, true),
		avocado("avocado", 150, -3.45, -150000, true),
		grapes("grapes", -3, -1000, -10000, false);

	cout << setw(12) << left << apple.getName() << setw(12) << right << apple.getPrice() << setw(12) << apple.getWeight() << setw(12)
		<< apple.getQuantity() << setw(12) << boolalpha << apple.getIs_purchased() << '\n';
	cout << setw(12) << left << orange.getName() << setw(12) << right << orange.getPrice() << setw(12) << orange.getWeight() << setw(12)
		<< orange.getQuantity() << setw(12) << boolalpha << orange.getIs_purchased() << '\n';
	cout << setw(12) << left << banana.getName() << setw(12) << right << banana.getPrice() << setw(12) << banana.getWeight() << setw(12)
		<< banana.getQuantity() << setw(12) << boolalpha << banana.getIs_purchased() << '\n';
	cout << setw(12) << left << avocado.getName() << setw(12) << right << avocado.getPrice() << setw(12) << avocado.getWeight() << setw(12)
		<< avocado.getQuantity() << setw(12) << boolalpha << avocado.getIs_purchased() << '\n';
	cout << setw(12) << left << grapes.getName() << setw(12) << right << grapes.getPrice() << setw(12) << grapes.getWeight() << setw(12)
		<< grapes.getQuantity() << setw(12) << boolalpha << grapes.getIs_purchased() << '\n';
}



apple                  4        4.56           4        true
orange                 5        2.65           7       false
banana                 2        2.34           4        true
avocado                0           0         150        true
grapes                 0           0           0       false

I modified it so the output looks something like this.

You created 5 objects:
# 1 of 5 objects:
 name: apple;  quantity: 4;  weight: 4.56;  price: $4;  was it purchased?: true

# 2 of 5 objects:
 name: orange;  quantity: 7;  weight: 2.65;  price: $5;  was it purchased?: false


# 3 of 5 objects:
 name: banana;  quantity: 4;  weight: 2.34;  price: $2;  was it purchased?: true

# 4 of 5 objects:
 name: avocado;  quantity: 150,023;  weight: -3.45;  price: $150000;  was it purchased?: true


# 5 of 5 objects:
 name: grapes;  quantity: -3;  weight: -1000;  price: $-10000;  was it purchased?: false


can anyone help with constructor #2. really confused on
how to incorporate everything from the instructions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Compiler directives
#include <iostream> // for cin, cout, endl
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;

// provide at least 4 attributes of different types
class Fruit {
public:
    Fruit() {}
    //Fruit(const std::string& z, int qty, double wgt, float prc, bool isp) :
    //name(z), quantity(qty), weight(wgt), price(prc), is_purchased(isp) {}
    Fruit(const std::string& z, int qty, double wgt, float prc, bool isp) :
    name(z), is_purchased(isp) {
        setQuantity(qty), setWeight(wgt), setPrice(prc);
    }

    void setName(const std::string& x) { name = x; }
    auto getName() const { return name; }

    void setQuantity(int q) { if (q >= 0) quantity = q; }
    auto getQuantity() const { return quantity; }

    void setWeight(double w) { if (w > 0) weight = w; }
    auto getWeight() const { return weight; }

    void setPrice(float p) { if (p >= 0) price = p; }
    auto getPrice() const { return price; }

    void setIs_purchased(bool i) { is_purchased = i; }
    auto getIs_purchased() const { return is_purchased; }

private:
    string name;
    int quantity {};
    double weight {};
    float price {};
    bool is_purchased {};
};
    
    struct Fruit_t{
        int quantity{};
        double weight{};
        float price{};
        bool is_purchased{};
    };
    // provide 2 constructors (default with no parameters and 2nd with parameters), setters, getters.
    
    /*
     default constructor: sets all the members to their default values – if in doubt, use the
     default initializers for the values, such as: int amount{}; it is a “default fruit” whatever that is.
     
     
    constructor #2    The new fruit's name, amount, weight, etc. are arguments. Calls the individual
     setters (below) to validate and set the
    variable.

     set_name    Accept a string argument and copies it into the name variable
     set_amount    Accepts an int argument and copies it into amount variable, but ONLY if >= 0
     set_weight    Accept a float argument and copies it into the weight variable if valid
     set_price   Accepts a double argument and copies it into the price, if reasonable
     
     
     Retrieval of data is done with getters:

     Member Function/Method    Description 

     get_name    Returns the value in name

     get_amount    Returns the value of rooms

     get_weight    Returns the value of square_feet

     get_prie    Returns the list_price of the house


cout a string to output a full description:

     name: orange, amount:3, weight:7.5, price: $25

     */
    

/*
 Provide two constructors: one for a “default” object, and one for an object where all the initial
 values are provided. Provide setters that validate new values and changes data members if OK.
 Provide getters. One of the getters should be a show / display / print / cout getter that shows
 all information about the object.  Another getter should show some combination of data members,
 such as: get_price_per_sqft, which performs a calculation and then produces a result:
 get_price_per_sqft() returns list_price / square_feet.
 
 
 After the class is working, create at least 5 different, separate instances of the class,
 such as: fruit1, fruit2, ... fruit5. Create 3 instances with all valid data and 2 instances
 with some (attempted) invalid data. .
 (apple, orange, pear, grapes, avocado)

 Setters should NOT change existing valid member values to invalid values. If given
 invalid data in a setter, reject it. Do not change the value.
 
 Modify the program to ask: "How many objects do you want?". Loop as many times specified
 by the user (5 is enough for testing) to create that many objects. You can use 5 individual
 variables, or you can use an array or vector. Submit one .cpp file. Do not create the class
 in a separate file.
 
 */


int main() {
    Fruit apple("apple", 4, 4.56, 4, true),
        orange("orange", 7, 2.65, 5, false),
        banana("banana", 4, 2.34, 2, true),
        avocado("avocado", 150, -3.45, -150000, true),
        grapes("grapes", -3, -1000, -10000, false);

/*
 Constructors and setters should ensure that invalid values are not accepted for attributes.
 For example, some values cannot be negative; a list price would not be negative, etc.
 Other validation may apply, such as the number of rooms could be only 1 to 20, perhaps.
 
 If given invalid data in a constructor, modify it to some reasonable default value. An easy,
 quick, safe default is to use a default number, like 0. Your choice. Constructors do not
 interact with the user. Don’t ask the user to correct invalid data inside the constructor.
 The constructor has to work independently of whether there is a user sitting at a
 keyboard or not. Constructors, setters and getters need to work under many circumstances –
 as when there is NO user sitting at a screen with a keyboard.
 
 Setters should NOT change existing valid member values to invalid values.
 If given invalid data in a setter, reject it. Do not change the value.
 To get the values for the data, you can “hard code” the data – using literals,
 or you can ask the user for data using a get_input function. Allow the user
 to enter negative values so invalid values can be presented to the class
 constructors and setters. Data validation is a key reason for having
 constructors and setters.
 
 The testing code should test each member function: constructors,
 setters and getters. Your driver code should create at least 5
 instances of your class and display the contents of each instance.
 Demonstrate using the class by writing test code that exercises
 all the methods. It is important to test all the code you write.

 */
    cout << "This program creates at least 5 separate, co-existing instances of a\n"
            "custom designed object. Information about each object is displayed.\n"
            "Each constructor, setter and getter is tested at least once.\n";
    
    
    cout <<"\nname:" <<apple.getName() <<"   price:"<< apple.getPrice()
    << "  weight:"<< apple.getWeight() << "  quantity:" << apple.getQuantity()
    <<"  was it purchased?:"<< boolalpha << apple.getIs_purchased() << '\n';
    
    
    cout << "name:" << orange.getName() << "  price:" << orange.getPrice()
    << "  weight:"<< orange.getWeight() << "  quantity:" << orange.getQuantity()
    << "  was it purchased?:"<< boolalpha << orange.getIs_purchased() << '\n';
    
    cout << "name:" << banana.getName() << "  price:" << banana.getPrice()
    << "  weight:"<< banana.getWeight() << "  quantity:" << banana.getQuantity()
    << "  was it purchased?:"<< boolalpha << banana.getIs_purchased() << '\n';
    
    cout << "name:" << avocado.getName() << " price:" << avocado.getPrice()
    << "  weight:"<< avocado.getWeight() << "     quantity:" << avocado.getQuantity()
    << "  was it purchased?:"<< boolalpha << avocado.getIs_purchased() << '\n';
    
    cout << "name:" << grapes.getName() << "  price:" << grapes.getPrice()
    << "  weight:"<< grapes.getWeight() << "     quantity:" << grapes.getQuantity()
    << "  was it purchased?:"<< boolalpha << grapes.getIs_purchased() << '\n';
    
    
    cout << "\nThis ends the class design, implementation, test program. Goodbye!\n";
    return EXIT_SUCCESS;
}   // end of main 
Pages: 1234