ok i got everything to add a record and display what have i added now the real problem is how do i get them to show the largest and smallest wingspan??heres my code:
Code:
#include <iostream.h>
#include<string.h>
#include<iomanip.h>
#include<stdio.h>
#include <conio.h>
class animal{
public:
char *Desc;
float Height;
float Weight;
char *getDesc(void){return Desc;}
float getHeight(void){return Height;}
float getWeight(void){return Weight;}
void setanimal (char *desc, float height, float weight){
Desc = new char[strlen(desc)+1];
strcpy(Desc, desc);
Height = height;
Weight = weight;}
void PrintAllInfo(){
cout<<"Desc: "<<getDesc()<<endl;
cout<<"Height : "<<getHeight()<<endl;
cout<<"Weight : "<<getWeight()<<endl;
}
};
class bird: public animal{
public:
float Wingspan;
float getWingspan(void){return Wingspan;}
void setbird (float wingspan){Wingspan = wingspan;}
void PrintInfo(){
cout<<"Wingspan: "<<getWingspan()<<endl;}
};
void main(void) {
int choice;
bird BirdRec[9];
int x = 0,countera = 0;
char *Desc;Desc = new char[20];
float height,weight,wingspan;
do {
clrscr();
cout<<"[1]Add new Bird Rec"<<endl;
cout<<""<<endl;
cout<<"[2]Display all Bird's Record"<<endl;
cout<<""<<endl;
cout<<"[3]Display the bird with the largest winspan"<<endl;
cout<<""<<endl;
cout<<"[4]Display the bird with the smallest winspan"<<endl;
cout<<""<<endl;
cout<<"[5]Exit"<<endl;
cout<<""<<endl;
cout<<"Please Enter a number: ";
cin>>choice;
switch(choice){
case 1:
int choose;
do{
cout<<"Enter Birds Name: ";
gets(Desc);
cout<<"Enter height: ";
cin>>height;
cout<<"Enter weight: ";
cin>>weight;
cout<<"Enter wingspan: ";
cin>>wingspan;
BirdRec[x].setbird(wingspan);
BirdRec[x].setanimal(Desc,height,weight);
cout<<"Enter another Record?[1]Yes / [2]No";
cin>>choose;
x = x + 1;
}while(choose != 2);
break;
case 2:
int counter, y;
y = x - 1;
clrscr();
if (y < 0) {
cout<<"There is still no data of any Bird Recorded"<<endl;}
else {
for (counter = 0;counter <= y;counter=counter+1){
BirdRec[counter].PrintAllInfo();
BirdRec[counter].PrintInfo();
cout<<""<<endl;
}}
;
getch();
break;
case 5:
countera = 2;
}
}while(countera != 2);
i use switch to do the menu thing and i hope to do the case 3 and 4 for the largest and smallest wingspan thx