import java.util.Scanner;
public class enum1 {
public static void main(String[] args) {
proxyRequst a = new saler();
a.request();
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
TV hairerTV = new TV();
hairerTV.setChannel(x);
System.out.println("卖给用户hairTV目前的频道是:"+hairerTV.getChannel());
Chineses zhangzhi = new Chineses();
zhangzhi.buyTV(hairerTV);
System.out.println("zhangzhi开始看电视节目");
zhangzhi.seeTV();
int m;
System.out.print("请输入zhangzhi要看的频道:");
m = sc.nextInt();
System.out.println("zhangzhi将买回来的电视更改到"+m+"频道");
zhangzhi.remoteControl(m);
System.out.println("现在卖给用户的电视频道是"+hairerTV.getChannel());
System.out.println("zhangzhi在看电视");
zhangzhi.seeTV();
}
}
interface proxyRequst
{
abstract public void request();
}
class hairerTVFactory implements proxyRequst
{
public void request()
{
System.out.println("我是海尔公司,我想要设置初始频道为:");
}
}
class saler implements proxyRequst{
private hairerTVFactory a;
public void request()
{
if(a==null)
{
a = new hairerTVFactory();
a.request();
}
}
}
class TV
{
int channel;
void setChannel(int m)
{
if(m>=1)
{
channel = m;
}
}
int getChannel()
{
return channel;
}
void showProgram()
{
switch(channel){
case 1: System.out.println("综合频道");
break;
case 2:System.out.println("经济频道");
break;
case 3:System.out.println("文艺频道");
break;
default:System.out.println("不能看"+channel+"频道");
}
}
}
class Chineses
{
TV homeTV;
void buyTV(TV tv)
{
homeTV = tv;
}
void remoteControl(int m){
homeTV.setChannel(m);
}
void seeTV(){
homeTV.showProgram();
System.out.println("用户买回来的电脑是在"+homeTV.getChannel()+"频道");
}
}