chicken class implementation and execution

İptal Edildi İlan edilme: Apr 26, 2013 Teslim sırasında ödenir
İptal Edildi Teslim sırasında ödenir

Write a main program to exercise your Chicken class. This main program will use an array of 10 Chicken objects. The chickens will have laid 0, 1, 2,…, 9 eggs respectively. The chickens will weigh 3, 3.2, 3.4,…,4.8 kilograms respectively. The first 5 chickens will be in solitary confinement (position=CONFINED), otherwise they will be on the FARM. Every chicken will have attempted to escape once, however the first 2 chickens have attempted to escape 10 times. Finally, the program should output the attributes for the 10 chickens.

(5 pts) Bonus: compare the chickens to see if any chickens have attempted the same number of escapes and are currently in solitary confinement, i.e., use the operator overloaded function. If so, output which chickens matched, and their attributes using the appropriate outputAll method already written.

/** Begin code after this line **/

#include

using namespace std;

enum { FARM, CONFINED, UNKNOWN };

char locString[3][30] = { {"is on the farm"},

{"is in solitary confinement"},

{"cannot be found"}};

// Chicken class definition

class Chicken {

private:

int eggs,

escapes,

position;

float weight;

public:

Chicken(int, int, int, float); // Constructor

int getEggs(void);

int getEscapes(void);

void setEggs(int egg) { eggs=egg; };

void setEscapes(int escape) { escapes=escape; };

void setPosition(int pos) { position=pos; };

void setWeight(float w) { weight=w; };

void setAll(int,int,int,float);

void outputAll(int);

void outputAll(int,int,Chicken); // output compared chickens

/** Write operator overload definition here **/

};

// Constructor definition

Chicken::Chicken(int egg=0, int escape=0, int pos=UNKNOWN, float w=3.0) {

eggs = egg;

escapes = escape;

position = pos;

weight = w;

}

// Set all attributes

void Chicken::setAll(int egg, int escape, int pos, float w) {

eggs = egg;

escapes = escape;

position = pos;

weight = w;

}

// Output all attributes

void Chicken::outputAll(int n) {

cout << "Chicken [" << n+1 << "] has laid " << eggs << " eggs, "

<< "has escaped " << escapes << " times, "

<< "weighs " << weight << " kilograms, and " << locString[position] << endl;

}

// Output all attributes for 2 chickens that match criteria

void Chicken::outputAll(int n, int m, Chicken otherChick) {

cout << "Chicken [" << n+1 << "] matches with chicken [" << m+1 << "] "

<< "where each has escaped " << escapes << " times and are both in solitary confinement." << endl;

cout << "Chicken [" << n+1 << "] has laid " << eggs << " eggs and "

<< "weighs " << weight << " kilograms." << endl;

cout << "Chicken [" << m+1 << "] has laid " << [url removed, login to view] << " eggs and "

<< "weighs " << [url removed, login to view] << " kilograms.\n\n";

}

/** Write your operator overload implementation here **/

/** Write your main function here **/

/** End code before this line **/

C++ Programlama OpenGL

Proje NO: #4467144

Proje hakkında

3 teklif Uzak proje Aktif Apr 26, 2013

Bu iş için 3 freelancer ortalamada $56 teklif veriyor

dobreiiita

Hi, I am c++ expert, It is purely C++ based, I don't see any use of openGL, Am I right?

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(105 Değerlendirme)
5.8
rakib062

Please check private message.

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(10 Değerlendirme)
3.8
skysap

i can write the codes right now. one hour max.

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(0 Değerlendirme)
0.0