Question 6

Write C+++ statements to:

  1. Ask the user "How many dogs do you own?"
  2. Read in that many single word names (one for each dog) from the user and store the names in an array.
  3. After the user has entered the names, display them as in the example below (note the commas and period).

Sample run:

How many dogs do you own? 4
Ok, enter their names!
Cujo
BoneSnap
Brad
Muffins
The names you entered: Cujo, BoneSnap, Brad, Muffins.

Question 7

Complete the class dog so that the code in main works as described in the comments. The necessary constructor declarations are already provided for you. You may define the constructor and method bodies inside or outside the class, as you choose.

class dog
{
private:
	// all data members must be private

public:
	// public constructor declarations
	dog();
	dog(string breed, int weight);
	dog(int weight);

	// public method declarations go here

};

int main()
{
	dog bonny;
	dog wimpy;
	dog fido("rottweiler", 200);
	dog snuffles(15);

	bonny.setBreed("pit bull");
	bonny.setWeight(500);

	wimpy.setWeight(-300);

	bonny.speak(); //I'm a 500 lbs pit bull
	wimpy.speak(); //I'm a 0 lbs mutt
	fido.speak();  //I'm a 200 lbs rottweiler
	snuffles.speak(); //I'm a 15 lbs mutt

	bonny.switchBodies(fido);

	bonny.speak(); //I'm a 200 lbs rottweiler
	fido.speak();  //I'm a 500 lbs pit bull

	dog puppy;
	puppy = fido.mateWith(wimpy);

	puppy.speak(); //I'm a 250 lbs pit bull-mutt

	return 0;
}