这个调用方法的程序为什么大多分写两个类写?不太懂 下面是我变成一个类写的对么
public class telphone{
float screen;
float cpu;
float mem;
void call(){
System.out.println("telphone具有打电话的功能");
}
void sendMessage(){
System.out.println("screen"+screen+"cpu"+cpu+"mem"+mem+"telphone具有发短信的功能");
}
}
public class telphone{
public static void main(String[] args){
telphone phone=new telphone();
phone.screen=5.0f;
phone.cpu=1.5f;
phone.mem=2.0f;
phone.sendMessage();
phone.call();
}
}
public class telphone{
float screen;
float cpu;
float mem;
public static void main(String[] args){
telphone phone=new telphone();
phone.screen=5.0f;
phone.cpu=1.5f;
phone.mem=2.0f;
phone.sendMessage();
phone.call();
}
void call(){
System.out.println("telphone具有打电话的功能");
}
void sendMessage(){
System.out.println("screen"+screen+"cpu"+cpu+"mem"+mem+"telphone具有发短信的功能");
}
}