腾讯信息JAva

public class Mobiletelephone {
	Sim card;
	public void usesim(Sim card){
		this.card=card;
	}
	public void showmess(){
		System.out.println("使用的手机卡"+card.givecorpname()+"提供的");
		System.out.println("使用的手机卡"+card.givenumber()+"提供的");
	}
	

}



public abstract class Sim {
	public abstract void setnumber(String n);
	public abstract String givenumber();
	public abstract String givecorpname();	
	}



public class Mobiletelephone {
	Sim card;
	public void usesim(Sim card){
		this.card=card;
	}
	public void showmess(){
		System.out.println("使用的手机卡"+card.givecorpname()+"提供的");
		System.out.println("使用的手机卡"+card.givenumber()+"提供的");
	}
	

}



public class Simofchinamobile extends Sim {
	String number;
	public void setnumber(String n){
		number=n;
	}
	public String givenumber(){
		return number;
		
	}
	public String givecorpname(){
		return "中国移动" ;
	}

}



public class Simofchinaunicom extends Sim{
		String number;
		public void setnumber(String n){
			number=n;
		}
		public String givenumber(){
			return number;
			
		}
		public String givecorpname(){
			return "中国联通" ;
		}

	}




public class Test {

	public static void main(String[] args) {
	Mobiletelephone telephone=new Mobiletelephone();
	Sim sim=new Simofchinamobile();
	sim.setnumber("1386385851");
	telephone.usesim(sim);
	telephone.showmess();
	sim=new Simofchinamobile();
	sim.setnumber("130638589581");
	telephone.usesim(sim);
	telephone.showmess();

	}

}

你可能感兴趣的:(腾讯信息JAva)