C and Cpp

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingC and Cpp

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 30th, 2011, 09:22 AM
liveyks2k8 liveyks2k8 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 1 liveyks2k8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 35 sec
Reputation Power: 0
OOP - Create a class for Dogs - Please help

Hey, everyone. I've been working on a program that creates a class of dogs. It will tell their name, color and what kind of bark they have based on the size of the dog. I can't for the life of me figure out how to make this program work. I don't have any clue what I'm doing wrong. I was hoping someone could take a look at this and see if what I'm doing wrong is blatant, and maybe point me in the right direction.

Here is my header file:
Code:
//Name //CSC-101 //Chapter 8 Homework - My Dog #pragma once #include <iostream> #include <string> using namespace std; class myDog { public: myDog(void); ~myDog(void); void setDog(string name, string size, string color); //Sets the name, size and color of dog void getDog(string&, string&, string&) const; //Retrieves info void dogBark(string s); //Determines size of bark void printDog() const; //Prints information private: string name; //name variable string size; //size variable string color; //color variable string bark; //bark variable };


Here is the implementation file:
Code:
#include "myDog.h" //Name //CSC-1001 //Chapter 08 Homework - My Dog #include <iostream> #include <string> using namespace std; myDog::myDog(void) { } myDog::~myDog(void) { } void myDog::setDog(string n, string s, string c) { name = n; size = s; color = c; } void myDog::dogBark(string s) { if (s == "small") bark = "yip"; else if (s == "medium") bark = "woof"; else bark = "woof woof"; } void myDog::getDog(string& n, string& s, string& c) const { name == n; size == s; color == c; } void myDog::printDog() const { cout << myDog.name << " is a " << myDog.size << endl; cout << " and he barks like this: " << myDog.bark << endl; }


And here is the main program:
Code:
//Name //CSC-101 //Chapter 08 Homework - My Dog #include <iostream> #include <string> #include "myDog.h" using namespace std; //Start of main program int main() { //3 instances of my dog class - one for each dog myDog myDog1; myDog myDog2; myDog myDog3; //Variables to hold the dogs characteristics string name; string size; string color; string bark; //Input statement to retrieve the facts of dog 1 cout << "Please enter name, size and color" << endl; cin >> name >> size >> color; myDog1.setDog(name, size, color); myDog1.printDog(); //Input statement to retrieve the facts of dog 2 cout << "Please enter name, size and color" << endl; cin >> name >> size >> color; myDog2.setDog(name, size, color); myDog2.printDog(); //Input statement to retrieve the facts of dog 3 cout << "Please enter name, size and color" << endl; cin >> name >> size >> color; myDog3.setDog(name, size, color); myDog3.printDog();


I'm not asking anybody to spend their afternoon helping me to perfect this. Is there something blatant that I'm doing wrong? Is it close? I can't figure out what to do now. Any help is appreciated. Thanks.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingC and Cpp > OOP - Create a class for Dogs - Please help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap