zoukankan      html  css  js  c++  java
  • 第二十一次发博不知道用什么标题好

    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多敲敲,反正也没说博客园打卡不能两天一样的内容哈哈哈

  • 相关阅读:
    第二十一天作业
    第二十天:继承
    第二十天作业
    第十六天
    第十九天作业
    day53
    day52
    day51
    day50
    day44
  • 原文地址:https://www.cnblogs.com/shi-yuan/p/10781220.html
Copyright © 2011-2022 走看看