为什么这个java接口和抽象程序不起作用,我花了几乎一天的时间,但找不到任何答案。有人可以帮忙吗? 我正在学习java中的面向对象编程。 java 文件名为 Main.java 这是错误 - 错误:在类中找不到 main(String[]) 方法:Camera
// Interface for a smartphone camera
interface Camera {
void takePhoto();
}
// Interface for a smartphone media player
interface MediaPlayer {
void playMusic();
}
// Parent class for cell phones
class CellPhone {
String brand;
public CellPhone(String brand) {
this.brand = brand;
}
void makeCall(String number) {
System.out.println("Calling " + number + " with " + brand + " phone.");
}
}
// SmartPhone class extending CellPhone and implementing Camera and MediaPlayer
// interfaces
class SmartPhone extends CellPhone implements Camera, MediaPlayer {
SmartPhone(String brand) {
super(brand);
}
@Override
public void takePhoto() {
System.out.println("Taking a photo with " + brand + " smartphone.");
}
@Override
public void playMusic() {
System.out.println("Playing music on " + brand + " smartphone.");
}
}
public class Main {
public static void main(String[] args) {
SmartPhone Lava = new SmartPhone("Lava");
Lava.makeCall("123-456-7890");
Lava.takePhoto();
Lava.playMusic();
}
}