Programming assignment is to tweak the existing mammal

Assignment Help C/C++ Programming
Reference no: EM13163649

programming assignment is to tweak the existing Mammal program and create your own Vehicle program.

sample program:

#include <iostream>

using namespace std;


enum BREED {YORKIE, GERMAN, DANDIE, SHETLAND, DOBERMAN, LAB};

class Mammal
{  

public:

        Mammal() :itsAge(2), itsWeight(5) {}       // constructor
        ~Mammal(){}     // destructor          
       
        // accessors
        int GetAge() const {return itsAge;}
        void SetAge(int age) {itsAge = age;}
        int GetWeight() const {return itsWeight;}
        void SetWeight(int weight) {itsWeight = weight;}
       
       
        // other function members     
        void speak() const {cout << "Mammal sound!" << endl;}
        void Sleep() const {cout << "shhh. I'm sleeping. " << endl;}

protected:
          int itsAge;
          int itsWeight;
};


class Dog : public Mammal
{

public:
       Dog() : itsBreed(YORKIE){}       // constructor
       ~Dog(){}     // destructor       // accessors

       BREED GetBreed() const { return itsBreed;}

       void SetBreed(BREED breed) {itsBreed = breed;}
       int GetWeight() const {return itsWeight;}
       void SetWeight(int weight) {itsWeight = weight;}
   
      

        // other function members
       void WagTail() const {cout << "Tail Wagging.. " << endl;}
       void BegForFood() const {cout << " Begging for food " << endl;}

private:

           BREED itsBreed;
};
void main()
{
    Dog cooper;
    cooper.speak();
    cooper.WagTail();
    cout << "cooper is " << cooper.GetAge() << " years old. " << endl;

}


//Sample Run:
//Mammal sound!
//Tail wagging...
//cooper is 2 years old

 

This is a program that declares a class Mammal.

Class Mammal has all the generic attributes and functions.

Class Dog, inherits from class Mammal

At the beginning of the program, I am using and enumeration that is simply assigning integers from 0 to whatever the last value is

For example in

enum BREED {YORKIE, GERMAN, DANDIE, SHETLAND, DOBERMAN, LAB};

YORKIE will grab the value of zero and LAB will have the value of 5

I have used inline functions for most of the member functions because it cuts down on the amount of code, you do not have to do that if inline functions are not your favorites.

Copy and paste the program into your IDE and run it, it should run with no errors.

Then I would like you to modify the program and instead of Mammal and Dog, create a base class Vehicle and then create a class car that inherits from the class Vehicle.

You can have weight of the car, brand, topspeed, number of cylinders (e.g. 4 cylinders, V6, V8) and so forth

I would declare it as below:

enum Engine_Type {zero,one,two,three,four,five,V6,seven,V8};

in the enum above, I would be interested in four, V6, and V8, because they will take the values of 4, 6, and 8 repectively.

 

 

Reference no: EM13163649

Questions Cloud

Determine the values for m and l for the b+ tree : A B+-tree is to be stored on disk whose block size is 2048 bytes. The data records to be stored are 50 bytes, and their key is 4 bytes. Determine the values for M and L for the B+-tree. Assume pointers are 4 bytes each.
Let ll be a list of integers : Let LL be a list of integers. Use list comprehension to produce teh following lists. Each one should just take onel line. Anser questions as two comments.
Write a select statement that returns these columns : Write a SELECT statement that returns these columns from the Products table: The date_added column A column that uses the CAST function to return the date_added column with its date only (year, month, and day)
You will write a program that reads a text file : You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..
Programming assignment is to tweak the existing mammal : programming assignment is to tweak the existing Mammal program and create your own Vehicle program.
Program that uses an instance of the timeoff : Write a program that uses an instance of the TimeOff class you designed in Programming Challenge 5. The program should ask the user to enter the number of months an employee has worked for the company. It should then use the TimeOff object to calc..
Find the number of steps per revolution. : If a given stepper motor has a step angle of 5 degrees, find the number of steps per     Revolution.
Boolean algebraic multiple choice question : boolean algebric mulitiple choice question
What are the requirements regarding plaintext and ciphertext : Keeping the IV secret in OFB mode does not make an exhaustive key search more complex. Describe how we can perform a brute-force attack with unknown IV. What are the requirements regarding plaintext and ciphertext?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a c function to convert gallons-quarts-pints and cups

Write a C function named liquid() that is to accept an integer number and the addresses of the variables gallons, quarts, pints, and cups.

  Perform operations on arrays

Perform operations on arrays execute tests and repetitions

  Ruby implement primitive types

How does Ruby implement primitive types, such as those for integer and floating-point data?  3-What is the single most important practical difference between Smalltalk and C++?

  A run is a sequence of adjacent repeated val

A   run   is   a   sequence   of   adjacent   repeated   values.   Using   an   array,   write   a   program   that   generates   a   sequence   of

  Principle ofsuperposition to determine that system is linear

Apply the principle of superposition to determine whether the following systems are linear. Sketch what the plot of the function looks like.

  Create a template class

Create a template class, SVector, that implements a constructor

  Write a program that allows users to enter a dollar amount

Write a program that allows users to enter a dollar amount for their bank account balance at the beginning of the month. Then ask the user to enter a dollar amount for any number of checks written in a month, up to 50. Include an approriate sentinel ..

  Assume that section

Assume that section _1 seats are in front of the stage, and the price is expensive. say, each seat in the 1st three rows is $180.00, and each seat in the last two rows is 10% less;

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  The fibonacci sequence

In the novel "The DaVinci Code", a scrambled version 13, 3, 2, 21, 1, 1, 8, 5 of the first eight Fibonacci numbers appear as one of the clues left by murdered museum curator Jacques Sauniere. In this assignment, we will do something related to t..

  Program to enter number of values to be processed

Write c++ statements to permit the user to enter n, the number of values to be processed; then assign the anonymous array of n double values, storing its address in doublPtr.

  Writing a program that creates a linked list

Writing a program that creates a linked list from 100 randomly generated numbers and sorts the using a heap. One heap in ascending order and one heap in descending order. Then displays the original linked list and both sorted lists.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd