2020.09.16 과제 기초자바

 package e_oop;


public class Watch {


boolean hello ; // 전화를 받고 끊는것

    int volume ; //전화중에 볼륨을 조절한다. 

    int exercise; //운동량 체크 

boolean ring;

    

    final int MIN_VOLUME = 0 ; 

    final int MAX_VOLUME = 10 ; 

final int MIN_EXERCISE = 0 ; 

final int MAX_EXERCISE = 7 ; 

Watch() {

hello = false ; 

volume = 5 ; 

exercise = 0 ; 

ring = false;

}

void hello (){ 

hello = !hello; 

System.out.println( hello ?  "전원연결" : "전원꺼짐" );

}

void exerciseup(){

if(hello){

if(exercise < MAX_VOLUME){

exercise++;

}

showExercise(); 

}

}

void showExercise(){

System.out.print("운동량"); 

for ( int i = MIN_EXERCISE + 1 ; i <= MAX_EXERCISE; i++){

if (i <= exercise){

System.out.print("👍");

    

}

}

}


   void volumeUp() { 

    if (hello){

    if ( volume < MAX_VOLUME) {

    volume++;

    }

    showVolume(); 

    }

    }

    void volumeDown() { 

    if(hello){

    if ( volume > MIN_VOLUME) { 

    volume--; 

    }

    showVolume();

    }

    }

        void showVolume(){ 

    System.out.print("음량 ");

    for ( int i = MIN_VOLUME + 1 ; i <= MAX_VOLUME; i++){

    if( i <= volume){

    System.out.print("♥"); 

    }else {

    System.out.println("❤");

    }

    }

   

    }

    

    

    void ring(){ 

    ring = !ring;

    System.out.println( ring ? "전화받기" : "전화걸기");

    

    }

    

    

    

    

    

    

    

    

    

    

    

    

    public static void main(String[] args) {

    Watch watch = new Watch();

   

   

    while(true){ 

    System.out.println("~~~~~~~~~~~~~~~~~~~~~"); 

    System.out.println("1.전화 2.볼륨업  3.볼륨 다운 "); 

    System.out.println("4.운동량입력 ");

    System.out.println("~~~~~~~~~~~~~~~~~~~~~"); 

    System.out.print("번호입력>"); 

    int input = ScanUtil.nextInt(); 

    switch (input) {

    case 1 : watch.hello(); break ; 

   

   

    case 2 : watch.volumeUp(); break; 

    case 3 : watch.volumeDown(); break;

    case 4 : watch.showExercise(); break;

    default:

    System.out.println("바쁜 당신을 위해 늘 준비되어 있습니다.");

    break; 

    }

   

   

   

    }

   

   

    }

   

 

   

   

    }

 

    

    

    

    


댓글