第二十一次发博不知道用什么标题好

package java Test1;
public class Kettle{
    private int volume;
    
    public Kettle(int volume){
        this.volume=volume;
    }

    public int heatngWater(int needWater){
    int actualWater = 0;
    if(needWater>volume){
        System.out.println("太多啦装不下"+needWater+"升水");
    }else{
        actualWater=needWater-1;
        System.out.println("烧开了"+actualWater+"升水");
    }
    return actualWater;
    }
}



package javaTest1;
import java.util.Scanner;

public class TestKettle{


    public static void main(String[] args){

        Scanner read = new Scanner (System.in);
        System.out.println("请输入水壶的容积");
        Kettle k1 = new Kettle(read.nextInt());
        System.out.println("请输入要烧的水量");
        k1.heatingWater(read.nextInt);
        }

}

这个烧水的例子之前老师就讲过了但是我老感觉不懂,emmm多敲敲,反正也没说博客园打卡不能两天一样的内容哈哈哈

猜你喜欢

转载自www.cnblogs.com/shi-yuan/p/10781220.html