java中怎么编写这个程序?
以下是参考资料importjava.util.Scanner;importjavax.xml.crypto.Data;publicclassVehicle{private...
以下是参考资料
import java.util.Scanner;
import javax.xml.crypto.Data;
public class Vehicle { private static int g18; private String MotoVehicle; private String car; private String bus; public void MotoVehicle(){ String No; String Brand; String Color; String Mileage; } public void Car(){ String gl8="别克商务舱"; String i550="宝马"; String road="别克林荫"; } public void Bus(){ int championship=10; int goldendragon=16; } public void CalcRent(int days){ int g18=600; int i550=500; int road=300; int championship=800; int goldendragon=1500; } public static void main(String[]args){ Scanner sc = new Scanner(System.in); System.out.println("请输入要租的车型号:"); System.out.println("请输入天数:"); int Vehicle = sc.nextInt(); for(g18 = 1;g18>=600;g18++){ System.out.ptinyln("您的型号是:"+"g18"+"您所租的天数是:"+day+"需要:"g18+"元") } }}
编写到这我就不会了 求大神 展开
import java.util.Scanner;
import javax.xml.crypto.Data;
public class Vehicle { private static int g18; private String MotoVehicle; private String car; private String bus; public void MotoVehicle(){ String No; String Brand; String Color; String Mileage; } public void Car(){ String gl8="别克商务舱"; String i550="宝马"; String road="别克林荫"; } public void Bus(){ int championship=10; int goldendragon=16; } public void CalcRent(int days){ int g18=600; int i550=500; int road=300; int championship=800; int goldendragon=1500; } public static void main(String[]args){ Scanner sc = new Scanner(System.in); System.out.println("请输入要租的车型号:"); System.out.println("请输入天数:"); int Vehicle = sc.nextInt(); for(g18 = 1;g18>=600;g18++){ System.out.ptinyln("您的型号是:"+"g18"+"您所租的天数是:"+day+"需要:"g18+"元") } }}
编写到这我就不会了 求大神 展开
2个回答
展开全部
一看就知道必须是三个类。
首先是作为父类的抽象类MotoVehicle:
public abstract class MotoVehicle{
String no;
String color;
String brand;
int mileage;
public MotoVehicle(String no){
this.no=no;
}
public abstract CalcRent(int days);
}
其次是两个final的子类car和bus
final class Car extends MotoVehicle{
String type;
public Car(String on,String type){
super(on);
this.type=type;
}
public CalcRent(int days){};
}
final class Bus extends MotoVehicle{
int seatCount;
public Bus(String on,int seatCount){
super(on);
this.seatCount=seatCount;
}
public CalcRent(int days){};
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询