Write a class named Dog that contains: Three member variables named breed, age, sex and maturity...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a class named Dog that contains: Three member variables named breed, age, sex and maturity where breed, sex and maturity are strings and age is an integer. • Accessor and mutator functions for all member variables. A default constructor that initializes all strings to the empty string and the age to zero. . A constructor that accepts breed, age, sex and maturity as arguments and initializes the corresponding member variables. A fix function that changes the sex to "fixed". An overloaded + operator. The result of adding 2 dogs together is another dog with an age of zero, maturity as "puppy", and a breed of "cross" if the two dogs being added together are of different breeds or the same breed as the dogs being summed if they are of the same breed. The resulting sex of the dog is to be female. If either of the dogs to be added together are "fixed" or both dogs are of the same sex, then the overloaded operator should simply return a default dog (one initialized with the default constructor). Note: Write class specification and implementation in files Dog.h and Dog.cpp respectively. Write a "driver" program (main() function) that creates 4 dogs (not as an array) a male golden retriever, a female labrador retriever and two fixed german shephards. The age of the dogs should all be set to 1. The maturity of the dogs should be set to "adult". Display the result of adding the golden and the lab together and the two german shephards together. I . . Write a class named Dog that contains: Three member variables named breed, age, sex and maturity where breed, sex and maturity are strings and age is an integer. • Accessor and mutator functions for all member variables. A default constructor that initializes all strings to the empty string and the age to zero. . A constructor that accepts breed, age, sex and maturity as arguments and initializes the corresponding member variables. A fix function that changes the sex to "fixed". An overloaded + operator. The result of adding 2 dogs together is another dog with an age of zero, maturity as "puppy", and a breed of "cross" if the two dogs being added together are of different breeds or the same breed as the dogs being summed if they are of the same breed. The resulting sex of the dog is to be female. If either of the dogs to be added together are "fixed" or both dogs are of the same sex, then the overloaded operator should simply return a default dog (one initialized with the default constructor). Note: Write class specification and implementation in files Dog.h and Dog.cpp respectively. Write a "driver" program (main() function) that creates 4 dogs (not as an array) a male golden retriever, a female labrador retriever and two fixed german shephards. The age of the dogs should all be set to 1. The maturity of the dogs should be set to "adult". Display the result of adding the golden and the lab together and the two german shephards together. I . .
Expert Answer:
Answer rating: 100% (QA)
Below is the implementation for the Dog class along with the specified member functions and the main driver program Dogh ifndef DOGH define DOGH include class Dog private stdstring breed int age stdst... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Write a program that accepts seconds and displays corresponding days, hours, minutes, and seconds. Repeat the process if the user wants to continue. Use input validation for valid input. Run your...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
John Black is considering to purchasing a land from Real Estate Ltd for $1,000,000. The terms of the agreement are, 10% down payment, and the balance is to be repaid at 20% interest for duration of...
-
Harold Perto purchased 100 shares of Barclays, a U.K. financial services firm, when they were trading for 260 (pounds sterling) and the exchange rate between British pounds and U.S. dollars was $1.50...
-
Simplify the irrational number \(\sqrt{2,548}\) and express in lowest terms. Identify the rational and irrational parts.
-
Suppose that we are trying to value a three-period call option on a stock that will either go up by 7 percent or down by 4 percent per period, that the exercise price of the option is $35, that the...
-
Using MAD, determine whether the forecast in Problem 5-13 or the forecast in the section concerning Wallace Garden Supply is more accurate.
-
1 - Affiliated to Al Noor Industrial Company Unit selling price 18 dinars Direct materials 6 dinars Direct work 4 dinars Variable industrial costs 3 dinars Fixed industrial costs 100,000 dinars...
-
Comparative Statements of Retained Earnings for Renn Dever Corporation were reported as follows for the fiscal years ending December 31, 2022, 2023, and 2024. No preferred stock or potential common...
-
As shown, a shaft is composed of five cylindrical sections. A motor is attached at F and supplies the shaft with P = 175.0 kW at a speed of w=160 rad/s. This power is transferred through the shaft...
-
You take a summer job working for a family friend as a Web page designer for a small information technology service. On your first payday, the owner slaps you on the back, gives you full payment in...
-
You are an audit supervisor who has just received from an auditor a set of working papers. The auditor has obeyed some of the rules for preparing working papers but has violated others. You plan to...
-
Many employers are switching to payroll cards instead of issuing paper payroll checks to employees. Go to the American Payroll Association Website (www.americanpayroll.org) and select PaycardPortal...
-
As the accountant for Prestige Home Construction you record your employers workers compensation costs. At a meeting discussing the year-end financial statements, your boss, Dusty Haynes, says, We...
-
Purposes of an accounting system include all of the following except: a. Interpret and record the effects of business transactions. b. Classify the effects of transactions to facilitate the...
-
answer whth explantion 4. The following table gives the daily income of ten workers in a factory. 0 answers
-
For a Poisson process of rate , the Bernoulli arrival approximation assumes that in any very small interval of length , there is either 0 arrivals with probability 1- or 1 arrival with probability ....
-
Add a method insertionSort to the class ArraySorter, as given in Listing 7.10, that performs an insertion sort of an array. To simplify this project, our insertion sort algorithm will use an...
-
Write a Java program that displays the following picture. Write a sequence of println statements that display lines of asterisks and blanks. **** ** * **** ****** * ** ************** **** ** **
-
Write statements that can be used in a Java program to read your age, as entered at the keyboard, and display it on the screen.
-
Identify the issues related to performance evaluation using DCF models.
-
Identify relevant cash flows for DCF analyses.
-
Andrea Boss, Inc. is interested in using its activity-based costing system to improve its operating efficiency and its profit margins by applying activity-based management techniques. As part of this...
Study smarter with the SolutionInn App