In this project, you will create a class called Camel. Below, we will describe what will define a Camel. You will also create a main function in which you will create objects of type Camel to test the functionality of your new user-defined type. In the main, you will create enough objects of your new type(s) in order to adequately test their functions. It is up to you to do this properly.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Code C++
In this project, you will create a class called Camel. Below, we will
describe what will define a Camel. You will also create a main function in
which you will create objects of type Camel to test the functionality of
your new user-defined type. In the main, you will create enough objects
of your new type(s) in order to adequately test their functions. It is up to
you to do this properly.
Your Camel class is to contain the following:
Member variables:
• a float for weight
• a short for age (months)
• a string for name
• a char for gender
• a bool to indicate whether alive (or not)
Member functions:
• a default constructor that creates a dead camel
• a constructor that you can pass values to so as to establish its
gender, weight, age, and name; it will default to alive.
• a print function that will output to the screen the attributes of that
camel in a nice, easy to read format.
• an age_me function that returns nothing but increments the object's
age.
• an eat function that increases the weight of the camel by a random
amount from 0.1% to 5.0% of the camel' current weight.
Note: Think very carefully about writing the above functions and how
they should be used. There are indeed circumstances when some
functions should not execute. For example, a dead camel shouldn't eat
anything.

Step by step
Solved in 2 steps with 1 images









