有同学能帮我看一下我写的有啥问题嘛
题目:利用抽象类和接口知识点编写一个功能
例如 手机 >非智能手机>智能手机
抽象类的基本属性 手机的基本属性
抽象类的抽象方法 基本电话功能
接口
1,有摄像和拍照功能
2,蓝牙功能
3,定位功能
代码:package com.dmd;
public abstract class phone {
private String brand;
private int price;
public abstract void call();
public abstract void message();
public phone(String brand, int price) {
System.out.println("Basic attributes and functions");
this.brand = brand;
this.price = price;
this.call();
this.message();
}
public interface photograph {
public void photograph();
}
public interface bluetooth {
public void bluetooth();
}
public interface location {
public void location();
}
}
public abstract class phone {
private String brand;
private int price;
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public abstract void call();
public abstract void message();
}
public interface phoneInterface {
public void photograph();
public void bluetooth();
public void location();
}
public class zhinengPhone extends phone implements phoneInterface {
@Override
public void call() {
System.out.println(this.getBrand()+"打电话功能");
}
@Override
public void message() {
System.out.println(this.getBrand()+"发短信功能");
}
@Override
public void photograph() {
System.out.println(this.getBrand()+"拍照功能");
}
@Override
public void bluetooth() {
System.out.println(this.getBrand()+"蓝牙功能");
}
@Override
public void location() {
System.out.println(this.getBrand()+"定位功能");
}
public static void main(String[] args) {
zhinengPhone zhinengPhone=new zhinengPhone();
zhinengPhone.setBrand("华为");
zhinengPhone.setPrice(8888);
zhinengPhone.call();
zhinengPhone.message();
zhinengPhone.photograph();
zhinengPhone.location();
zhinengPhone.bluetooth();
}
}