當前位置:名人名言大全網 - 短信平臺 - java 編寫手機短信,高手賜教!!!

java 編寫手機短信,高手賜教!!!

package examples;

import java.util.Scanner;

public class Entry {

public static void main(String args []) {

Scanner sc=new Scanner(System.in);

String pno,msg;

System.out.print("請輸入短信內容:");

msg=sc.nextLine();

System.out.println("請輸入目標手機號碼:");

pno=sc.nextLine();

ShortMesg newmsg=new ShortMesg();

newmsg.setPhoneNO(pno);

newmsg.setMessage(msg);

SendMesg send=new SendMesg(newmsg);

send.send();

}

}

class ShortMesg {

public ShortMesg() {

}

private String pno,msg;

public void setPhoneNO(String pno) {

this.pno=pno;

}

public String getPhoneNO() {

return this.pno;

}

public void setMessage( String msg) {

this.msg=msg;

}

public String getMessage() {

return this.msg;

}

}

class SendMesg {

private ShortMesg mms;

public SendMesg(ShortMesg mms) {

this.mms=mms;

}

public void send() {

System.out.println("短信內容: "+mms.getMessage());

System.out.println("目標手機: "+mms.getPhoneNO()+"\n");

}

}