게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
[본삭금] C++코드 동물키우기게임 만들고있는데 너무 막막합니다..
게시물ID : programmer_10948짧은주소 복사하기
작성자 : 오르락
추천 : 0
조회수 : 1113회
댓글수 : 2개
등록시간 : 2015/06/07 02:57:09
옵션
  • 베스트금지
  • 본인삭제금지

후... 내일까지 제출인 과제인데요..

아 오늘이군요 ㅠㅠ

C++로 동물키우기 게임 만들고있는데요..

동물의 능력치(포만감, 위생 등등...)를 30으로 주어주는 형식으로 만드려고하는데

스테이터스창도 어떻게 만들어야할지 모르겠고 너무 막막해요 도와주세요..ㅠㅠ

어떠한식으로 짜야될지 조언좀해주세요..ㅠㅠ


#include <iostream>
#include <string>
using namespace std;

class Animal
{
 int status;
 string animal[4];
public:
 Animal() {
  animal[0] = "강아지", animal[1] = "악어", animal[2] = "돼지", animal[3] = "곰";
 }

 void SelectAnimal()
 {
  cout << "1." << animal[0] << endl;
  cout << "2." << animal[1] << endl;
  cout << "3." << animal[2] << endl;
  cout << "4." << animal[3] << endl;
  int temp;
  while (true){
   cout << "1~4중 하나를 선택해주세요 : ";
   cin >> temp;
   switch (temp)
   {
   case 1:
    cout << animal[0] << "를 선택하셨습니다." << endl;
    status = 1;
    break;
   case 2:
    cout << animal[1] << "를 선택하셨습니다." << endl;
    status = 2;
    break;
   case 3:
    cout << animal[2] << "를 선택하셨습니다." << endl;
    status = 3;
    break;
   case 4:
    cout << animal[3] << "를 선택하셨습니다." << endl;
    status = 4;
    break;
   default:
    cout << "선택하신 숫자에 해당하는 동물이 존재하지 않습니다." << endl;
    continue;
   }
   if (temp == 0 || temp == 1 || temp == 2 || temp == 3)
    break;
  }
 }

 string getAnimal()
 {
  return animal[status-1];
 }
};


class Name
{
 string name;
 string petName;
public:
 void setName()
 {
  cout << endl << endl;
  cout << "=======================================" << endl;
  cout << "당신의 이름(별칭)을 입력하세요." << endl;
  cout << "->";
  cin >> name;
 }

 void setPetName(string pets)
 {
  cout << pets << "의 별칭을 입력하세요." << endl;
  cout << "->";
  cin >> petName;
 }


 string getName()
 {
  return name;
 }
 string getpetName()
 {
  return petName;
 }
 void show()
 {
  cout << "==========[" << getName() << "]의 [" << getpetName() << "] 키우기==========" << endl;
 }
};

class Menu
{
public:
 void selectMenu()
 {
  int temp;
  cout << endl << endl;
  cout << "===================================" << endl;
  cout << "================메뉴===============" << endl;
  cout << "1. 상태보기" << endl;
  cout << "2. 먹이주기 (포만감+)" << endl;
  cout << "3. 씻기기 (위생+)" << endl;
  cout << "4. 놀아주기 (스트레스-, 애정도+)" << endl;
  cout << "【주의 : 메뉴 (2, 3, 4 중 하나 선택 시 하루가 지남) *" << endl;
  cout << "【하루가 지날 때마다 [ 포만감-1 ]  [ 위생-1 ] [ 스트레스+[0~1] ] [ 애정도-1 ]" << endl;
  /*while (true){
  cout << "1~4중 하나를 선택해주세요 : ";
  cin >> temp;
  switch (temp)
  {
  case 1:
  state();
  break;
  case 2:
  food();
  break;
  case 3:
  clean();
  break;
  case 4:
  play();
  break;
  default:
  cout << "잘못 된 번호입니다." << endl;
  continue;
  }
  if (temp == 0 || temp == 1 || temp == 2 || temp == 3)
  break;
  }*/
 }
 void state()
 {

 }
 void food();
 void clean();
 void play();
};
//
//class State
//{
//public:
//   State()
//   {
//      get
//   }
//
//};

//class Dog
//{
//};
//class Alligator
//{
//};
//class Pig
//{
//};
//class Bear
//{
//};

int main()
{
 Animal animal;
 Name name;
 Menu menu;

 cout << "동물 키우기 게임이 시작됩니다!" << endl;
 animal.SelectAnimal();
 name.setName();
 name.setPetName(animal.getAnimal());
 name.show();
 menu.selectMenu();
}

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호