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
-
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...
-
A sales engineer has the following alternatives .to consider in touring his sales territory. (a) Buy a new car for $14,500. Salvage value is expected to be about $5000 after 3 years. Maintenance and...
-
What does it mean if someone invests in a mutual fund? In a stock market fund?
-
Brian Rafferty ingested finasteride, a drug prescribed to him to treat an enlarged prostate. Finasteride is a generic version of Proscar, a drug manufactured by Merck. Some time after he started to...
-
On January 1, 2014, Bensen Company leased equipment to Flynn Corporation. The following information pertains to this lease. 1. The term of the noncancelable lease is 6 years, with no renewal option....
-
XYZ Corp. produces 1,000 units of output (along the same isoquant) using various combinations of capital (K) and labor (L). At point A (along the same isoquant), the firm uses 30 units of capital and...
-
The towline exerts a force of P = 4 kN at the end of the 20-m-long crane boom. If x = 25 m, determine the position ? of the boom so that this force creates a maximum moment about point O. What is...
-
A piece of insulation consists of a layer of material A and a layer of material B, each of thickness L, but with different thermal conductivities. Suppose that the insulation separates a reservoir at...
-
Describle a service failure and how/Why is this relevant to service operations management? Relate to 1 or more of the service dimensions, Which service gap? Include relevant real data to justify the...
-
What is the implications of the following project and do you have any recommendation?
-
What is the competition like in the airline industry (you can focus on the industry using your criteria)? What do you as the key success factors for firms in the airline business?
-
ces Suppose Riverside sells its canoes for $513 each. Calculate the contribution margin per canoe and the contribution margin ratio. Note: Round your contribution margin to the nearest whole dollar...
-
XYZ Company has a D/E ratio of 1.0. If the company needs to raise $800, the dollar amount of financing coming from equity is $_______?
-
Boneta City College sold season tickets for the 2016 football season for $250,000. A total of 8 games will be played during September, October and November. In September, three games were played. The...
-
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.
-
Why is the analyzing step of the process crucial to the success of a MedImmune proposal? In the discussion, draw students attention to the intersection of medical, legal, and social issues. Why is...
-
How does the Clinical Trial Application guide described in the example make the composing process for a new document easier? How is it informed by the evaluation process? What metaphors or analogies...
-
Review how the ACE process led to the improved message by answering the following questions. 1. What information in the revised version addresses the need for persuasion? 2. How does the email...
Study smarter with the SolutionInn App