面向对象-----代码练习(以水杯为例)
package com.hanqi; public class Cup { String YanSe; String PinPai; double ShuiBeiRongLiang; double DangQianRongLiang; public int DQRL= 80; public void jiaShui(double shuiliang){ DangQianRongLiang += shuiliang; System.out.println("拿着"+YanSe+"的"+ PinPai +"水杯加了"+shuiliang+"毫升水"); } }
运行结果: