I have a few assignments to get done, but I figured I'll post one to see if I'm the right track. If so then what I did will greatly help me.
Here are the requirements
Create a simple Dog class that has the following private fields (age (int), gender(char), name(string), hungry(boolean) and the following public functions(speak(), eat(), getName(), getAge(), getGender(), setAge(int), and printDetails() )
This is what I've written so far. I know there are errors, but this is mainly because I'm stuck at how to do the char. I also commented out the printDetails as I'm confused on how to go about doing that, so for now I resorted to cout.
Did I do this thing entirely wrong or am I doing it a harder way then I have to?
// dogassignment.cpp : Defines the entry point for the console application.
// David Tarantula
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class dog{
private:
int age;
int hungry;
char gender;
string name;
public:
string speak();
string eat();
string getName();
char getGender();
int getAge();
void setAge(int a);
void setName(string n);
void setGender(char g);
// void printDetails();
};
int dog::getAge(){
return age;
}
void dog::setAge(int a){
age = a;
}
char dog::getGender(){
return gender;
}
void dog::setGender(char g){
gender = g;
}
string dog::getName(){
return name;
}
void dog::setName(string n){
name = n;
}
int main(){
dog davesDog;
davesDog.setAge(1);
davesDog.setName("Cody");
davesDog.setGender("M");
cout << "The dog is " << davesDog.getAge() << " years old." << endl << endl;
cout << "The dog's gender is " << davesDog.getGender() << endl << endl;
cout << "His name is " << davesDog.getName() << "." << endl;
system("pause");
return 0;
}