package JUL.JUL.JUL18.phone; public abstract class Phone { private String brand; private String type; public Phone(){} public Phone(String brand ,String type){ this.setBrand(brand); this.setType(type); } public String getType() { return type; } public void setType(String type) { this.type = type; } public void setBrand(String brand) { this.brand =Brand; } public String getBrand () { return Brand; } // texting public void sendInfo () { the System. OUT .println ( " Send SMS .... " ); } // called public void Call () { . System OUT .println ( " was on the phone ,,,, " ); } public void info () { System. OUT .println ( " mobile phone brand: " + the this.getBrand()+"\n型号:"+this.getType()); } }
package JUL.JUL.JUL18.phone; public interface Photo { void photo(); } package JUL.JUL.JUL18.phone; public interface Net { void net(); } package JUL.JUL.JUL18.phone; public interface Play { void play(String str); }
package JUL.JUL.JUL18.phone; public class ZN_Phone extends Phone implements Net,Play,Photo { public ZN_Phone(){} public ZN_Phone(String brand ,String type){ super(brand, type); } @Override public void net() { System.out.println("上网中。。。。"); } @Override public void photo() { System.out.println("拍照中。。。"); } @Override public voidPlay (String STR) { the System. OUT .println ( " Now Playing:" " + STR + " " " ); } }
package JUL.JUL.JUL18.phone; public class PT_Phone extends Phone implements Play { public PT_Phone(){} public PT_Phone(String brand ,String type){ super(brand,type); } @Override public void play(String str) { System.out.println("播放歌曲:《"+str+"》"); } }
JUL.JUL.JUL18.phone Package; public class the Test { public static void main (String [] args) { ZN_Phone Zn = new new ZN_Phone ( " Millet " , " millet 5SP " ); PT_Phone Pt = new new PT_Phone ( " Nokia " , " Nokia A3 " ); System. OUT .println ( " *************** smartphone ****************** " ) ; zn.info (); zn.call (); zn.play (" Re-linking " ); zn.photo (); zn.sendInfo (); zn.net (); . System OUT .println ( " *************** ordinary phone ** ********************************************************* " ); pt.info (); pt.call (); pt.sendInfo (); pt.play ( " solution summer " ); } }