MotorVehicle抽象クラスを持つプログラムを作成することになっています。Car、Truck、Vanの種類ですMotorVehicle。setTerms()とは唯一のdisplayInfo()抽象です。と、と)、 と を持っCarています。String transTypevoid Car()Vanint numPassengervoid Van(Truckdouble payLoadvoid Truck()
出力は次のようになります。
ブランドはマツダ
車種はセダン
カラーはレッド
トランスミッションタイプはオートマチック
価格は840000.0です
支払い期間は5年です
ブランドはいすゞ
車種はトラック
カラーはホワイト
ペイロード容量は 3.5
価格は910000.0です
支払い期間は 3 年です
ブランドは三菱
車種はファミリーバン
カラーはブルー
乗客数は8人です
価格は1050000.0です
支払い期間は7年です
しかし、私のプログラムはまだこの出力を生成しません
これが私の現在のコードです:
public abstract class MotorVehicle
{
    private String vehicleType;
    private String brand;
    private String color;
    private String terms;
    public MotorVehicle(String vcl, String brn, String clr, String trm)
    {
        vehicleType = vcl;
        brand = brn;
        color = clr;
        terms = trm;
    }
    public String getVehicleType()
    {
        return vehicleType;
    }
    public String getBrand()
    {
        return brand;
    }
    public String getColor()
    {
        return color;
    }
    public abstract void setTerms();
    public abstract void displayInfo();
}
//=========================================
public class Car extends MotorVehicle
{
    String transType="";
    String vehicleType;
        String brand;
    String color;
    String terms;
    int price = 0;
    public Car(String vcl, String brn, String clr, String trm)
    {
        super(vcl, brn, clr, trm);
        vehicleType = vcl;
        brand = brn;
        color = clr;
        terms = trm;
    }
    public void Car()
    {
        brand = "Mazda";
        vehicleType = "Sedan";
        color = "Red";
        transType = "Automatic";
        price = (int) (700000 + (700000*0.2));
        Double.toString(price);
        terms = "5";   
    }
    public void setTerms()
    {
         return;
    }
    public void displayInfo()
    {
        System.out.println("Brand is " + brand);
        System.out.println("Vehicle type is " + vehicleType);
        System.out.println("Color is " + color);
        System.out.println("Transmission type is " + transType);
        System.out.println("Price is " + price);
        System.out.println("Terms is " + terms + " years to pay");
    }
}
//=================================
public class Truck extends MotorVehicle
{
    double payLoad=0.0;
    String vehicleType;
        String brand;
    String color;
    String terms;
    int price = 0;
    public Car(String vcl, String brn, String clr, String trm)
    {
        super(vcl, brn, clr, trm);
        vehicleType = vcl;
        brand = brn;
        color = clr;
        terms = trm;
    }
    public void Truck()
    {
        brand = "Isuzu";
        vehicleType = "Truck";
        color = "White";
        payLoad = 3.5;
        Double.toString(payLoad);
        price = (int) (700000 + (700000*0.3));
        Double.toString(price);
        terms = "3";     
    }
    public void setTerms()
    {
         return;
    }
    public void displayInfo()
    {
        System.out.println("Brand is " + brand);
        System.out.println("Vehicle type is " + vehicleType);
        System.out.println("Color is " + color);
        System.out.println("Payload capacity is " + payLoad);
        System.out.println("Price is " + price);
        System.out.println("Terms is " + terms + " years to pay");
    }   
 }
//==========================
public class Van extends MotorVehicle
{
    int numPassenger=0;
    String vehicleType;
        String brand;
    String color;
    String terms;
    int price=0;
    public Van(String vcl, String brn, String clr, String trm)
    {
            super(vcl, brn, clr, trm);
        vehicleType = vcl;
        brand = brn;
        color = clr;
        terms = trm;
    }
    public void Van()
    {
    brand = "Mitsubishi";
    vehicleType = "Family Van";
    color = "Blue";
    numPassenger = 8;
    String.valueOf(numPassenger);
    price = (int) (700000 + (700000*0.5));
    Double.toString(price);
    terms = "7";   
}
public void setTerms()
{
     return;
}
public void displayInfo()
{
    System.out.println("Brand is " + brand);
    System.out.println("Vehicle type is " + vehicleType);
    System.out.println("Color is " + color);
    System.out.println("Number of passenger is " + numPassenger);
    System.out.println("Price is " + price);
    System.out.println("Terms is " + terms + " years to pay");
}
}
//===================
そして、これがメインプログラムです:
public class MainVehicle 
{
    public static void main(String[] args)
    {
        BBVehicle[] vhl= new BBVehicle[3];
        int ctr=0;
        while(ctr<3)
        {
            if (ctr==0)
                vhl[ctr]=new Car();
            else if(ctr==1)
                vhl[ctr]= new Truck();
            else
                vhl[ctr]= new Van();
            vhl[ctr].displayInfo();
            ctr++;
        }
     }
}
プログラムの何が問題なのかわかりません。助けてくださいありがとう