#ifndef COMPETITIONCLASS_H
#define COMPETITIONCLASS_H
#include <string>
#include <fstream>
using namespace std;
struct parent
{
std::string mother;
std::string father;
};
class Competition
{
private:
std::string breed;
std::string name;
std::string color;
std::string owner_lastname;
parent parents;
int age;
int position;
public:
void initCat(void);
void printCatInfo(void);
void saveToFile(ofstream& file);
};
#endif // !COMPETITIONCLASS_H
#include <iostream>
#include <fstream>
#include "competitionclass.h"
using namespace std;
void Competition::initCat(void)
{
cout << "Enter breed of cat: ";
getline(cin, breed);
cout << "Enter name of cat: ";
getline(cin, name);
cout << "Enter color of cat: ";
getline(cin, color);
cout << "Enter mother of cat: ";
getline(cin, parents.mother);
cout << "Enter father of cat: ";
getline(cin, parents.father);
cout << "Enter owner lastname: ";
getline(cin, owner_lastname);
cout << "Enter age: ";
cin >> age;
cout << "Enter position: ";
cin >> position;;
}
void Competition::printCatInfo(void)
{
cout << "Breed: " << breed << endl;
cout << "Name:" << name << endl;
cout << "Color: " << color << endl;
cout << "Age: " << age << endl;
cout << "Mother: " << parents.mother << endl;
cout << "Father: " << parents.father << endl;
cout << "Owner lastname: " << owner_lastname << endl;
cout << "Position: " << position << endl;
}
void Competition::saveToFile(ofstream& file)
{
file << "Breed: " << breed << endl;
file << "Name:" << name << endl;
file << "Color: " << color << endl;
file << "Age: " << age << endl;
file << "Mother: " << parents.mother << endl;
file << "Father: " << parents.father << endl;
file << "Owner lastname: " << owner_lastname << endl;
file << "Position: " << position << endl;
}