자바 9월 22 발표 게임만들기 - 내게임

My Traveler Game 

package t_game;

import e_oop.ScanUtil;

public class MyTravelerGame {//
Traveler c; 
MyTravelerGame(){///
c = new Traveler ( "오로라" , 50 , 40, 70, 30 );
}///

public static void main(String[] args) {////
// TODO Auto-generated method stub

new MyTravelerGame().start(); 
}////

   void start (){ /////
   int input = 0 ; 
   while(true) { //////
   System.out.println( " ๑•ิܫ•ั๑ 1.여권 \t ☼ 2.도전하기 \t ✤✥ 3. 여행끝내기 ");
       input = ScanUtil.nextInt(); 
       
       
       switch(input){ ///////
       case 1 : 
       c.TravelerDiary();
       break;
       case 2 : 
       challenge();
       break ; 
       case 3 : 
       System.out.println( "오늘의 여행이 끝났습니다 당신의 다음 여정을 기대합니다. "); 
           System.exit(0);
           break; 
       }///////
   
   }//////
   }/////
void challenge(){ //10
if ( c.level == 1 ){//1
     Obstacle q = new Obstacle ("떠날 수 있는 용기" , 20, 10,15, 10 ); 
     
     System.out.println(q.name + "가 필요합니다. 도전을 시작합니다. 비행기표를 끊으세요"   );
     int input = 0 ; 
       battle : while(true) { //2
       System.out.println("1. 비행기표를 구매하시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ //3
       case 1 : 
       c.attack(q); 
       if (q.hp <= 0 ){ //4
      System.out.println( q.name +"를 장착하셨습니다. 여행을 떠납니다. ");
      c.getExp(100);
      break battle ; 
       }//4
       q.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("여행은 항상 우리 곁에 있습니다.");
       break battle ; 
       }//3
}//2
       }//1
   
   if ( c.level == 2 ){ 
     Obstacle w = new Obstacle ( "파리의 소매치기" , 30, 20, 25, 20); 
     System.out.println(w.name + "를 만났습니다. 도전을 시작합니다.");
   
     int input = 0 ; 
       battle : while(true) {
       System.out.println("1. 도전하시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ 
       case 1 : 
       c.attack(w); 
       if (w.hp <= 0 ){ 
      System.out.println( w.name +" 를 물리쳤습니다. 파리의 마지막 여정 아름다운 에펠탑을 보러 몽파르나스타워를 방문합니다. ");
      c.getExp(100);
      break battle ; 
       }
       w.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("여행은 즐거우셨습니까?");
       System.out.println("지금 인천국제공항으로 착륙하고 있습니다. 현지시간은 2050년 5월 19일 17시 입니다.");
       System.out.println("저희 Air France Developer 를 이용해 주셔서 감사합니다 ");
       break battle ; 
       }
}
       }
   
   
   
   
   
   
   
   
       if ( c.level == 3) {
     Obstacle y = new Obstacle ("뉴욕의 상상초월 월세 " ,40, 30, 35, 30); 
     System.out.println(y.name + "를 위해 돈이 필요합니다. 도전을 시작합니다. 직업을 구하세요 돈을 버세요");
     int input = 0 ; 
       battle : while(true) {
       System.out.println("1. 돈벌기에 도전하시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ 
       case 1 : 
       c.attack(y); 
       if (y.hp <= 0 ){ 
      System.out.println( y.name +" 를 냈습니다. 뉴욕의 센트럴파크에서 푸릇한 여름을 느끼세요. ");
      c.getExp(100);
      break battle ; 
       }
       y.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("뉴욕 여행은 즐거우셨습니까?");
       System.out.println("저희 Delta Developer 를 이용해 주셔서 감사합니다 ");
       break battle ; 
       }
}
       
       
       
       }
   if ( c.level == 4 ){ 
    Obstacle p = new Obstacle ("캘거리의 - 30도의 겨울날씨 " ,30, 20, 45, 40);   
    System.out.println(p.name + "속에 있습니다. 도전을 시작합니다. 견디시겠습니까?"   );
    int input = 0 ; 
       battle : while(true) {
       System.out.println("1. 5겹의 옷을 입고 견디시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ 
       case 1 : 
       c.attack(p); 
       if (p.hp <= 0 ){ 
      System.out.println( p.name +" 를 견디셨습니다. 귀여운 YOSI를 보러가세요. ");
      c.getExp(100);
      break battle ; 
       }
       p.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("캐나다의 여행은 즐거우셨습니까?");
       System.out.println("지금 우리비행기는 인천국제공항에 착륙하고 있습니다. 현지시간은 2059년 2월 10일 18시 입니다.");
       System.out.println("저희 Air Canada Developer 를 이용해 주셔서 감사합니다 ");
       break battle ; 
       }
}
   
   }
       if ( c.level == 5 ){ 
    Obstacle z = new Obstacle ("벤쿠버의 하루종일 내리는 비" ,30, 30, 35, 30);     
    System.out.println(z.name + "를만나 우울지수가 올라갔군요. 도전을 시작합니다."   );
       
    int input = 0 ; 
       battle : while(true) {
       System.out.println("1. 우울함을 이겨내시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ 
       case 1 : 
       c.attack(z); 
       if (z.hp <= 0 ){ 
      System.out.println( z.name +" 로인한 감정적 피로를 견디셨습니다. 벤쿠버의 봄여름을 즐기세요. ");
      c.getExp(100);
      break battle ; 
       }
       z.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("여행은 즐거우셨습니까?");
       System.out.println("지금 우리비행기는 인천국제공항에 착륙하고 있습니다. 현지시간은 2050년 5월 19일 17시 입니다.");
       System.out.println("저희 CanadaDeveloper 항공을 이용해 주셔서 감사합니다 ");
       break battle ; 
       }
}
       
       
       
       }
       if ( c.level == 6 ){ 
        Obstacle k = new Obstacle ("비엔나는 지하철에서 구글맵 사용이 제한" ,40, 30, 35, 30);   
        System.out.println(k.name + "됬군요 종이 지도를 읽으시겠습니까? 언어는 통하지 않아도 누군가에게 도움을 청하실 수 있습니다. "   );
       
       
        int input = 0 ; 
       battle : while(true) {
       System.out.println("1. 도전하시겠습니까? 2. 여행을 포기하고 고향으로 돌아가시겠습니까?");
       input = ScanUtil.nextInt(); 
       
       switch ( input ){ 
       case 1 : 
       c.attack(k); 
       if (k.hp <= 0 ){ 
      System.out.println( k.name +" 되어 있어 종이지도를 얻고 영어를 못하는 현지인과 바디랭귀지로 소통을하셨습니다.");
      System.out.println( "벨베데레 궁전으로 가셔서 클림트의 그림을 감상하세요 ");
      System.out.println( "❥❤❥ 모든 국가의 여행을 끝냈습니다. 축하합니다 ❥❤❥ " );
      System.out.println("현재 우리 비행기는 인천국제공항에 착륙하고 있습니다. 현재시간은 2020년 9월 22일입니다.");
      System.out.println("저희 Developer 에어라인을 이용해주셔서 감사합니다. "); 
      break battle ; 
       }
       k.attack(c);
       break; 
       
       
       case 2 : 
       System.out.println("오스트리아 여행은 즐거우셨습니까?");
       System.out.println("현재 우리 비행기는 인천국제공항에 착륙하고 있습니다. 현지시간은 2050년 5월 19일 17시 입니다.");
       System.out.println("저희 KlimtDeveloper 항공을 이용해 주셔서 감사합니다 ");
       break battle ; 
       }
}
       
       
       
       }
       
     
       
       
       }//10 
       
       
       
       
       
       
       
       
     
     
     
     
     
       
       
       
       
       
}//
--------------------------------------------------------------------------------------
Traveler 


package t_game;

public class Traveler {

String name; 
int maxHP; //최대체력
int hp ; //체력
int maxMp ; // 최대 마나
int mp ; // 마나 
int courage ; //용기 ( 공격력같은거 ) 
int calm ; // 방어력같은거 견딜 수 있는 능력치 
int exp ; //경험치 
int level ; // 레벨 -> 레벨이 진화할때마다 다른 곳에서 플레이를 하고 싶다. 
/*int items ; // 보유 아이템 정렬로 만들어 줄필요가 있다. 
*/
Traveler(String name, int hp , int mp , int courage, int calm){ 
this.name = name ; 
this.maxMp = hp ;
this.hp = this.maxHP ; 
this.mp = this.maxMp ; 
this.courage = courage; 
this.calm = calm ; 
this.level = 1 ; 
this.exp = 0 ;
//정렬로 만든 아이템이 들어가줘야함. 
}

//상태를 볼 수 있는 화면을 만들기 
void TravelerDiary() { 
System.out.println("✈✈안녕✈hola✈bonjour✈buon giorno✈hallo✈aloha✈✈" );
System.out.println("✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿ ❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿");
    System.out.println( "Welcome World traveler : 환영해  "); 
    System.out.println( "               <Your Passport>               " ); 
    System.out.println(" ♦Traveler's 이름 : " + name); 
    System.out.println(" ♦지금까지 방문한 국가 : " + level); 
    System.out.println(" ♦한걸음 더 나아갈 용기 : " + courage ); 
    System.out.println(" ♦여행을 지속할 감정적 평화지수 : " + calm); 
    System.out.println("♦♢♦♢♦♢♦♢♦♢♦♢♦♦♢♦♢♦♢♦♢♢♦♢여행자의 가방 속♦♢♦♢♦♢♦♢♦♢♦♢♦♢♦♢♦♢♦♢ "); 
    System.out.println("✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿ ❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿❀✿");
    //아이템부분을 만들어 주어야 한다. 
    
    System.out.println("--------------------------------------------------------- ");
}
void attack (Obstacle o ){ 
int damage = courage - o.calm;
//용기에서 방어력빼기 . 
damage = damage <=0 ? 1 : damage; 
o.hp = o.hp < damage ? o.hp - o.hp : o.hp - damage; 
}
//성숙함 
void getExp ( int exp ){ 
System.out.println(" ◕‿◕✿ 여행의 고단함 속에서 " + exp + " 만큼 성숙하셨습니다. ");
    this.exp += exp; 
    while ( 100<= this.exp ){ 
    levelUp(); 
    this.exp -=100; 
    }
}
    void levelUp (){ 
    level++; 
    //maxHp += 10 ; 
    maxMp += 10; 
    courage += 20 ;
    calm += 10 ; 
    //hp = maxHp; 
    mp = maxMp; 
    System.out.println(" level up !!!!!!! ✈축하합니다. 다음 도시로 이동하겠습니다.✈");
    //System.out.println("배와 비행기중에 선택하실 수 있습니다."); 
    // 배와 비행기를 선택했을 시에를 보여줌. 
    
  
    /* if ( level == 2 ) 
     *{ System.out.println ( "목적지로 
    */
    }
}
--------------------------------------------------------------------------------------
obstacle


package t_game;



public class Obstacle {
String name ;
int maxHp ; // 최대체력
int hp ; // 체력
    int maxMp; //최대마나
    int mp ; // 마나 
int courage ; //  감히 여행자를 힘들게 할만한 용기.  
int calm ; // 여행자가 용기로 이겨낼때 없어지는 추상적인 것을 표현 *이걸 설명해야함.  
int items; //보유 아이템 
int exp; //경험치 * 잘 생각해 보아야 할 부분
int level; // 레벨 
// 여기에 보유 아이템 즉 얘를 이겨냈을때 얻는 성과나 아이템에 대해서 정렬을 해주어야 함. 
//생성자 만들기 - 여러종류의 장애물이 하나의 클래스 사용. 이름이 달라지고 장애물이
//가진 속성이 달라짐 
Obstacle(String name, int hp, int mp, int courage, int calm ){
//아이템배열을 괄호 안에  써줘야함
this.name = name ; 
this.maxHp = hp ; 
this.courage = courage; 
this.calm = calm ; 
this.items = items; 
}
        
void attack (Traveler t){ 
int damage = courage - t.calm;
//얘네들이 가지고 있는 가상한 용기에서 트레블러의 침착함을 빼기
damage = damage <=0 ? 1 : damage ; 
t.hp = t.hp < damage ? t.hp - t.hp : t.hp - damage ; 
System.out.println(name + "은 여행자에게 큰 영향을 끼치고 있습니다."+ 
"여행자" + t +"에게" + damage + "만큼의 감정적 동요와 심리적 불안을 안겨주고었습니다. " );
System.out.println("여행자" + t.name + "의 남은 체력 : " + t.hp );
}
//아이템 배열 만들어줘야함. 
}



댓글