马家河子java,java程序

case 4:System.out.println("国际频道");

break;

case 5:System.out.println("体育频道");

break;

default:System.out.println("不能收看"+channel+"频道");

}

}

}

MainClass.java

public class MainClass {

public static void main(String args[])

{

TV haierTV=new TV();

haierTV.setChannel(5);

System.out.println("haierTV的频道是"+haierTV.getChannel());

Family zhangSanFamily=new Family();

zhangSanFamily.buyTV(haierTV);

System.out.println("zhangSanFamily开始看电视节目");

zhangSanFamily.seeTV();

int m=2;

System.out.println("zhangSanFamily将电视更换到"+m+"频道");

zhangSanFamily.remoteControl(m);

System.out.println("haierTV的频道是"+haierTV.getChannel());

System.out.println("zhangSanFamily再看电视节目");

zhangSanFamily.seeTV();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
编写程序模拟两个村庄共同拥有一片森林。编写一个Village类,该类有一个int型成员变量用于模拟林森中树木的数量。(参见5.14上机实践)。两个村庄的名字分别为:Red River 和 Whiterun。在森林中已经存在200棵树,在主类的主方法里面创建两个村庄,一个村庄进行了植树活动,改变了treeAmount的值,另外一个村庄调查了森林中的树木情况,并把观察到的树木的总数显示了出来。 请按下面的方式对书上程序的一些改动。 System.out.println(name + "植树" + n + "棵");=> System.out.println(n + " trees are planted in the " + name); System.out.println(name + "砍伐" + n + "棵");=> System.out.println(n + " trees are cut down in the " + name); System.out.println("无树木可发");=> System.out.println(" There is no tree for felling" ); System.out.println(name + "增加了" + n + " 人");=> System.out.println(n + "persons are add in the " + name ); System.out.println("森林中有" + leftTree + " 棵树");=> System.out.println("There are " + leftTree + " trees in the forest" ); System.out.println("赵庄的人口:" + zhaoZhuang.peopleNumber);=> System.out.println("The population of the Red River is " + zhaoZhuang.peopleNumber); System.out.println("马家河子的人口:" + maJiaHeZi.peopleNumber);=> System.out.println("The population of the Whiterun is " + maJiaHeZi.peopleNumber); 【输入形式】请输入赵庄种植树木的数量。 【输出形式】书上的模版显示下列信息: There are 200 trees in the forest 50 trees are planted in the Red River There are 250 trees in the forest 70 trees are cut down in the Whiterun There are 180 trees in the forest The population of the Red River is 100 12 persons are add in the Red River The population of the Red River is 112 The population of the Whiterun is 150 10 persons are add in the Whiterun The population of the Whiterun is 160
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值