-1

こんにちは皆さん、以下のプログラムに問題があり、「パブリッククラスのCellularPhoneで識別されていないメインメソッド」と私に言い続けています。どんな助けでも感謝します。

セクション 1: CellularPhoneクラス

public class CellularPhone
{

private String phoneBrand; // variable get phone brand
private String cellularCarrier; // variable see cellular carrier
private String phoneColor; // variable to get phone color

// Accesor Method
//method to return the Phone Brand

public String getphoneBrand()
{
return this.phoneBrand;
}

// method to return cellular carrier
public String getCellularCarrier()
{
return this.cellularCarrier;
}

//method to return phone color
public String getPhoneColor()
{
return this.phoneColor;
}
//********************************************************

//Mutator method

//method to change phone brand
public void setCellularBrand(String setCellularBrand)
{
this.phoneBrand=setBrand;
}
//method to change cellular carrier
public void setCellularCarrier(String setCellularCarrier)
{
this.cellularCarrier=setCarrier;
}
//method to change phone color
public void setPhoneColor(String setPhoneColor)
{
this.phoneColor=setColor;
}
} // end CellularPhone

セクション 2 CellularPhoneDriverクラス

import java.util.Scanner;

public class CellularPhoneDriver
{

    public static void main(String[] args)
    {
        Scanner std= new Scanner(System.in);

        firstCellularPhone= new CellularPhone(); // Creation of first phone (instantiation)
        secondCellularPhone= new CellularPhone(); // Creation of second phone (instantiation)
        thirdCellularPhone= new CellularPhone(); // Creations of third phone (instantiation)

        firstCellularPhone.setBrand("Apple"); // Setting brand for first phone
        firstCellularPhone.setCarrier("AT&T"); // Setting cellular carrier for first phone
        firstCellularPhone.setColor("white"); // Set color to phone first phone

        secondCellularPhone.setBrand("Samsung"); // Setting brand for second phone
        secondCellularPhone.setCarrier("Verizon"); // Setting cellular carrier for second phone
        secondCellularPhone.setColor("blue"); // Set color to phone second phone

        thirdCellularPhone.setBrand("Motorola"); // Setting brand for third phone
        thirdCellularPhone.setCarrier("Sprint"); // Setting cellular carrier for third phone
        thirdCellularPhone.setColor("black"); // Set color to phone third phone


        System.out.println("The first phone is manufactured by "+firstCellularPhone.getPhoneBrand()+", licensed under "+firstCellularPhone.getCellularCarrier()+" and its color is "+firstCellularPhone.getPhoneColor()+".");
        System.out.println("The second phone is manufactured by "+secondCellularPhone.getPhoneBrand()+", licensed under "+secondCellularPhone.getCellularCarrier()+" and its color is "+secondCellularPhone.getPhoneColor()+".");
        System.out.println("The third phone is manufactured by "+thirdCellularPhone.getPhoneBrand()+", licensed under "+thirdCellularPhone.getCellularCarrier()+" and its color is "+thirdCellularPhone.getPhoneColor()+".");
        } // End class main
} // end class CellularPhoneDriver
4

1 に答える 1

7

CellularPhoneメソッドを持たないを実行しようとしているようですmain()。メソッドCellularPhoneDriverを含む実行する必要がありますmain

>java CellularPhoneDriver
于 2013-07-14T14:13:10.887 に答える