jnk1m
Foliage IT
jnk1m
전체 방문자
오늘
어제
  • 분류 전체보기 (209)
    • Today I Learned (34)
    • Java (47)
    • Database (15)
    • [NHN Academy] (27)
    • Spring (47)
    • HTML + CSS + JavaScript (11)
    • JSP (3)
    • Node.js (10)
    • React Native (2)
    • 기타 (8)
    • 스크랩 (5)

인기 글

최근 글

티스토리

hELLO · Designed By 정상우.
글쓰기 / 관리자
jnk1m

Foliage IT

기타

ToyStory.java

2022. 7. 22. 08:33

1.

package first;
public class Toystory {

    private String they = "They";
    public String getThey(){
        return this.they;
    }

    public void acting(String name, String gerund){
        System.out.println(name + " is "+ gerund+".");
    }
    public void act(String name,String verb){
        System.out.println(name+" "+verb+".");
    }

    public void speak(String name, String script){
        System.out.println(name + " said "+ "'"+script+"'");

    }
    public void speak(String name, String to,String script){
        System.out.println(name + " told "+to+", '"+script+"'");

    }

    public void look(String name, String obj){
        System.out.println(name + " looked "+obj+".");
    }
    public void walk(String name, String obj){
        System.out.println(name+" walked "+obj+".");
    }

    public static void main(String[] args){
        Toystory ts = new Toystory();
        Buzz buzz = new Buzz();
        Woody woody = new Woody();
        Spaceship spaceship = new Spaceship();
        spaceship.setState("crushed");
        spaceship.setDirection("Upside down");

        ts.acting(buzz.getName(), "standing on the bed");
        ts.look(woody.getName(), "around");
        ts.acting(woody.getName(), "surprised");
        ts.acting(buzz.getName(), "blinking his eyes");
        ts.acting(buzz.getName(), "looking around");
        ts.act(woody.getName(), "hided himself");
        buzz.communicateByRadio();
        ts.speak(buzz.getName(), "Do you read me. I don't answer my ship.");
        ts.look(buzz.getName(), "his spaceship");
        spaceship.getShipState();
        spaceship.getShipDirection();
        ts.speak(buzz.getName(), "It'll take weeks to repair.");
        ts.act(buzz.getName(), "opened the instrument panel on the arm");
        ts.speak(buzz.getName(), "Buzz Lightyear mission log start date 4:07. My ship is out of course on route to sector 12, crash land on a strange planet. The impact must have woke me from hyper-sleep.");
        ts.acting(buzz.getName(), "jumping on the bed");
        ts.speak(buzz.getName(), "Terrain seems a bit unstable.");
        ts.acting(buzz.getName(), "tapping the panel");
        ts.speak(buzz.getName(), "If the air is breathable and there seems to be no sign of intelligent life anywhere.");
        ts.act(woody.getName(), "poped up");
        ts.speak(woody.getName(), "Hello!");
        ts.speak(buzz.getName(), "Holly!");
        buzz.Razer();
        ts.speak(woody.getName(),buzz.getName(),"woah woah woah did I fright you? I didn't meant to. Sorry. My name is Woody and this is Andy's room. That's all I was planning to say and also there has been a bit of a mix-up. This is my spot to see the bed.");
        ts.look(buzz.getName(), woody.getBadge());
        ts.speak(buzz.getName(), woody.getName(), "Local law enforcement. It's about time you got here. I'm Buzz Lightyear, Space Ranger Universe Protection Unit. My ship is crash-landed here by mistake.");
        ts.walk(buzz.getName(), "away");
        ts.speak(woody.getName(), "Yes it's a mistake because you see the bed here is my spot");
        ts.walk(woody.getName(), "behind Buzz");
        ts.act(buzz.getName(), "turned around");
        ts.speak(buzz.getName(), "To repair my turbo boosters.. Do people still use fossil fuels? Have you discovered Cristal occlusion? Well let's see where we got");
        ts.walk(ts.getThey(), "to the spaceship");  

    }
}

class Buzz{ //버즈
    private String name = "Buzz";
    private String razer= "red razer";
    private String job = "Space Ranger";
    private String[] pointColor = {"green","purple"};

    public String getName(){
        return this.name;
    }
    public String getRazer(){
        return this.razer;
    }

    public void Razer(){
        System.out.println("Buzz shoot "+getRazer()+".");
    }

    public void communicateByRadio(){
        System.out.println("Buzz said 'Buzz Lightyear to Star Command. Star Command. Star Command come in.'");
    } 
}

class Spaceship{ //우주선
    private String name = "Spaceship";
    private String state;
    private String direction;

    public void setState(String state){
        this.state = state;
    }
    public void setDirection(String direction){
        this.direction = direction;
    }
    public String getName(){
        return this.name;
    }
    public String getState(){
        return this.state;
    }
    public String getDirection(){
        return this.direction;
    }
    public void getShipState(){
        System.out.println("Spaceship is "+getState()+".");
    }
    public void getShipDirection(){
        System.out.println("Spaceship is "+getDirection()+".");
    }
}

class Woody{
    private String name = "Woody";
    private String job = "Sheriff";
    private String badge = "the star shaped Shriff badge";
    private String[] pointColor = {"brown","yellow"};
    private boolean backString = false;

    public String getName(){
        return this.name;
    }
    public String getBadge(){
        return this.badge;
    }

    public void setBackString(boolean backString){
        this.backString = backString;
    }

    public void speakScript(){
        if(backString != false){
            System.out.println("There's a snake in my boot!");
        }
        
    }

}

 

2. 

package first;
abstract class Common{
  private String name;
  private String description;
  private String script;
  private String act;
 
  public void setName(String name){
    this.name = name;
  }
  public String getName(){
    return this.name;
  }
  public void setDescribe(String description){
    this.description = description;
  }
  public String getDescribe(){
    return this.description;
  }
  public String getScript(){
    return this.script;
  }
  public void setScript(String script){
    this.script = script;
  }
  public String getAct(){
    return this.act;
  }
  public void setAct(String act){
    this.act = act;
  }

 
  public void act(String name,String verb){
    System.out.println(name+" " +verb+".");
  }
  public void act(String name, String verb, String plus){
    System.out.println(name+" " +verb+" "+plus+".");
  }
  public void speak(String name, String script){
    System.out.println(name+ " said "+ "'"+script+"'");
  }
  public void speak(String from, String to,String script){
      System.out.println(from + " told "+to+", '"+script+"'");
  }
  public void look(String name, String plus){
      System.out.println(name + " looked "+plus+".");
  }
  public void walk(String name, String plus){
      System.out.println(name+" walked "+plus+".");
  }
}

class Buzz extends Common{ //버즈
  private String buzzObj;
  
  public String getBuzzObj(){
    return this.buzzObj;
  }
  public void setBuzzObj(String buzzObj){
    this.buzzObj = buzzObj;
  }
  
  public void laser(){
      System.out.println("Buzz shoot laser to Woody");
  }
  public void communicateByRadio(){
      System.out.println("Buzz radioed 'Buzz Lightyear to Star Command. Star Command. Star Command come in.'");
  } 
}

class Woody extends Common{
  private String woodyObj;
  
  public String getWoodyObj(){
    return this.woodyObj;
  }
  public void setWoodyObj(String woodyObj){
    this.woodyObj = woodyObj;
  }
}

class Spaceship extends Common{ 
  public void getShipState(){
      System.out.println("Spaceship is "+getDescribe()+".");
  }
}

public class ToyStory2 {
  public static void main(String[] args){
      Buzz buzz = new Buzz();
      buzz.setName("Buzz");
      String b = buzz.getName();
      Woody woody = new Woody();
      woody.setName("Woody");
      String w = woody.getName();
      Spaceship spaceship = new Spaceship();
      spaceship.setName("spaceship");
      String s = spaceship.getName();

      buzz.setAct("is stading");
      buzz.act(b,buzz.getAct(), "on the bed");
      
      buzz.setDescribe("around");
      buzz.look(b, buzz.getDescribe());
      woody.setAct("is suprised");
      woody.act(w,woody.getAct());
      buzz.setAct("is blinking his eyes");
      buzz.act(b,buzz.getAct());
      buzz.look(b, "around");
      woody.act(w,"hided himself");
      buzz.communicateByRadio();
      buzz.setScript("Do you read me. I don't answer my ship.");
      buzz.speak(b,buzz.getScript());

      buzz.look(b, s);
      spaceship.setDescribe("crashed and upside-down");
      spaceship.getShipState();

      buzz.setScript("It'll take weeks to repair.");
      buzz.speak(b,buzz.getScript());
      buzz.setBuzzObj("the instrument panel on the arm");
      buzz.act("opened", buzz.getBuzzObj());

      buzz.setScript("Buzz Lightyear mission log start date 4:07. My ship is out of course on route to sector 12, crash land on a strange planet. The impact must have woke me from hyper-sleep.");
      buzz.speak(b,buzz.getScript());
      buzz.act(b,"is jumping", "on the bed");
      buzz.speak(b,"Terrain seems a bit unstable.");
      buzz.setAct("is tapping");
      buzz.setBuzzObj("the panel");
      buzz.act(b,buzz.getAct(),buzz.getBuzzObj());
      buzz.speak(b,"If the air is breathable and there seems to be no sign of intelligent life anywhere.");
      woody.act(w,"poped up");
      woody.speak(w, b, "Hello!");
      buzz.speak(b,"Holly!");
      buzz.laser();
      woody.speak(b, w, "woah woah woah did I fright you? I didn't meant to. Sorry. My name is Woody and this is Andy's room. That's all I was planning to say and also there has been a bit of a mix-up. This is my spot to see the bed.");
      woody.setWoodyObj("a star shaped sheriff badge");
      buzz.look(b,woody.getWoodyObj());
      buzz.speak(b, w, "Local law enforcement. It's about time you got here. I'm Buzz Lightyear, Space Ranger Universe Protection Unit. My ship is crash-landed here by mistake.");
      buzz.walk(b, "away");
      woody.speak(w,"Yes it's a mistake because you see the bed here is my spot");
      woody.walk(w, "behind Buzz");
      buzz.act(b,"turned around");
      buzz.speak(b,"To repair my turbo boosters.. Do people still use fossil fuels? Have you discovered Cristal occlusion? Well let's see where we got");
      buzz.walk(b, "to the spaceship");

  }
}

3.

abstract class ToyBase{
  private String name;
  private String description;
  private String script;
  private String act;

  public ToyBase(String name){
    this.name = name;
  }
  public String getName(){
    return this.name;
  }
  public String getDescribe(){
    return this.description;
  }
  // public void setDescribe(String description){
  //   this.description = description;
  // }
  public String getScript(){
    return this.script;
  }
  public void setScript(String script){
    this.script = script;
  }
  public String getAct(){
    return this.act;
  }
  public void setAct(String act){
    this.act = act;
  }

 
  public void act(String name,String verb){
    System.out.println(name+" " +verb+".");
  }
  public void act(String name, String verb, String plus){
    System.out.println(name+" " +verb+" "+plus+".");
  }
  public void speak(String name, String script){
    System.out.println(name+ " said "+ "'"+script+"'");
  }
  public void speak(String from, String to,String script){
      System.out.println(from + " told "+to+", '"+script+"'");
  }
  public void look(String name, String plus){
      System.out.println(name + " looked "+plus+".");
  }
  public void walk(String name, String plus){
      System.out.println(name+" walked "+plus+".");
  }
}

class Buzz extends ToyBase{ //버즈
  public Buzz(String name, String buzzObj){
    super(name);
    this.buzzObj = buzzObj;
  }
  private String buzzObj;
  
  public String getBuzzObj(){
    return this.buzzObj;
  }
  public void setBuzzObj(String buzzObj){
    this.buzzObj = buzzObj;
  }
  
  public void laser(){
      System.out.println("Buzz shoot laser to Woody");
  }
  public void communicateByRadio(){
      System.out.println("Buzz radioed 'Buzz Lightyear to Star Command. Star Command. Star Command come in.'");
  } 
}

class Woody extends ToyBase{ //우디
  public Woody(String name, String woodyObj){
    super(name);
    this.woodyObj = woodyObj;
  }
  
  private String woodyObj;
  
  public String getWoodyObj(){
    return this.woodyObj;
  }
  public void setWoodyObj(String woodyObj){
    this.woodyObj = woodyObj;
  }

  




}

class Spaceship extends ToyBase{ 
  private String state;
  public Spaceship(String name, String state){
    super(name);
    this.state = state;
  }
  public String getState(){
    return this.state;
  }

  public void getShipState(){
      System.out.println("Spaceship is "+getState()+".");
  }
}

public class ToyStory3 {
  public static void main(String[] args){
      Buzz buzz = new Buzz("Buzz","the panel on the arm");
      String b = buzz.getName();
      Woody woody = new Woody("Woody","Woody's star shaped sheriff badge");
      String w = woody.getName();
      Spaceship spaceship = new Spaceship("spaceship","crashed and upside-down");
      String s = spaceship.getName();

      buzz.setAct("is stading");
      buzz.act(b,buzz.getAct(), "on the bed");
      
      buzz.setDescribe("around");
      buzz.look(b, buzz.getDescribe());
      woody.setAct("is suprised");
      woody.act(w,woody.getAct());
      buzz.setAct("is blinking his eyes");
      buzz.act(b,buzz.getAct());
      buzz.look(b, "around");
      woody.act(w,"hided himself");
      buzz.communicateByRadio();
      buzz.setScript("Do you read me. I don't answer my ship.");
      buzz.speak(b,buzz.getScript());

      buzz.look(b, s);
      spaceship.getShipState();

      buzz.setScript("It'll take weeks to repair.");
      buzz.speak(b,buzz.getScript());
      buzz.act(b,"opened", buzz.getBuzzObj());

      buzz.setScript("Buzz Lightyear mission log start date 4:07. My ship is out of course on route to sector 12, crash land on a strange planet. The impact must have woke me from hyper-sleep.");
      buzz.speak(b,buzz.getScript());
      buzz.act(b,"is jumping", "on the bed");
      buzz.speak(b,"Terrain seems a bit unstable.");
      buzz.setAct("is tapping");
      buzz.act(b,buzz.getAct(),buzz.getBuzzObj());
      buzz.speak(b,"If the air is breathable and there seems to be no sign of intelligent life anywhere.");
      woody.act(w,"poped up");
      woody.speak(w, b, "Hello!");
      buzz.speak(b,"Holly!");
      buzz.laser();
      woody.speak(b, w, "woah woah woah did I fright you? I didn't meant to. Sorry. My name is Woody and this is Andy's room. That's all I was planning to say and also there has been a bit of a mix-up. This is my spot to see the bed.");
      buzz.look(b,woody.getWoodyObj());
      buzz.speak(b, w, "Local law enforcement. It's about time you got here. I'm Buzz Lightyear, Space Ranger Universe Protection Unit. My ship is crash-landed here by mistake.");
      buzz.walk(b, "away");
      woody.speak(w,"Yes it's a mistake because you see the bed here is my spot");
      woody.walk(w, "behind Buzz");
      buzz.act(b,"turned around");
      buzz.speak(b,"To repair my turbo boosters.. Do people still use fossil fuels? Have you discovered Cristal occlusion? Well let's see where we got");
      buzz.walk(b, "to the spaceship");

  }
}
    '기타' 카테고리의 다른 글
    • [Git] 명령어 정리: 커밋 이후의 저장소 반영 내용 수정부터 원격 저장소와 로컬 연결 및 병합까지
    • [Git] 명령어 정리: 설치 및 초기 설정, 저장소 생성, 파일 추가와 커밋, 원격 저장소 업로드 + 에러 해결
    • 한글 2 byte의 기준은 무엇인가?
    • [Node.js] Day 09: 데이터 가져와서 출력하기3

    티스토리툴바