任务1:
赋值 - 0:静态、非静态
公共课剧场1
{
字符串电影名称;
int movieTime;
public static void main (String args[])
{
Theatre1 movie1 = new Theatre1();
Theatre1 movie2 = new Theatre1();
movie1.movieName = "狱卒";
movie1.movieTime = 630;
movie2.movieName = "leo";
movie2.movieTime = 720;
movie1.watch_movie();
movie2.watch_movie();
}
public void watch_movie()
{
System.out.println("观看过: " movieName " 放映时间: " movieTime);
}
}
观看次数:狱卒 演出时间:630
观看次数:leo 放映时间:720
退货声明
公开课EbReading
{
public static void main (String args[]){
EbReading 评估器 = new EbReading();
int 消耗单位 =assessor.reading();
System.out.println("CU" 消耗单位);
assessor.calculate(消耗单位);
}
public int Reading()
{
int unit1 = 100;
返回单位1;
}
public voidcalculate(int 消耗单位)
{
支付金额 = 消耗单位*10;
System.out.println("支付:" payment);
}
}
CU:100
工资:1000
在计算器中添加方法
公开课计算器
{
public static void main(String[] args)
{
计算器 calc = new Calculator();
calc.add();
}
public void add()
{
System.out.println(10 20);
}
}
//减去()
//乘法()
//除法()
公共课计算器1
{
int a = 10;
浮点数 b = 20.5f;
public static void main (String args[])
{
计算器 1 calc = new 计算器 1();
calc.add();
calc.sub();
calc.mult();
calc.div();
}
public void add()
{
浮动 c = a b;
System.out.println("加法:" c);
}
公共无效子()
{
浮动 c = a-b;
System.out.println("减法:" c);
}
public void mult()
{
浮动 c = a*b;
System.out.println("乘:" c);
}
public void div()
{
浮动 c = a/b;
System.out.println("分区: " c);
}
}
添加:30.5
减法:-10.5
乘法:205.0
除法:0.4878049
以上是任务的详细内容。更多信息请关注PHP中文网其他相关文章!