私のクラスのいくつかの変数を変換できる必要があります。私はブール変数WaGa(Workstation/Gamingコンピュータ用のスタンド)を持っています。もしそれが真実なら、ストリングWorGamを変換したいですJavaクラスの変数を変更するには
私はサービスとサポートの方法でこれをしなければなりませんが、失敗します。ドライバの内容を表示します。助けて。
あなたのworGam()
機能を修正する必要が
public class Graphics
//instance data
{
private int Ram;
private String Brand;
private int Res;
private int BiWi;
private int BaCl;
private boolean K4;
private boolean WaGa;
private String WorGam;
//boolean WaGa, boolean K4, int BaCl, int BiWi, int Res, String Brand, int Ram
public Graphics (int R, String B, int Re, int Bi, int Ba, boolean K4, boolean Wa, String Wor) // constructor
{
Ram = R;
Brand = B;
Res = Re;
BiWi = Bi;
BaCl = Ba;
K4 = K4;
WaGa = Wa;
Wor = WorGam;
}
public int get_Ram() //Accessor Method - there are 3 of them
{
return Ram;
}
public String get_Brand() //Accessor Method - there are 3 of them
{
return Brand;
}
public int get_Res() //Accessor Method - there are 3 of them
{
return Res;
}
public int get_BiWi() //Accessor Method - there are 3 of them
{
return BiWi;
}
public int get_BaCl()
{
return BaCl;
}
public boolean get_K4()
{
return K4;
}
public String WorGam(boolean WaGa)
{
String WorGam;
if (WaGa == true) {
return WorGam = "Workstation";
} else {
return WorGam = "True";
}
}
public String toString()
{
return ("Ram" + " " + Ram + ". " + "Brand:" + " " + Brand + ". " + "Resolution" + " " + Res + ". " + "Processer" + " " + BiWi + "." + " " + "Base Clock" + " " + BaCl+ " " + "K4?" + " " + K4+ " " +WorGam);
}
}
public class Graphicse_Driver
{
public static void main(String [] args)
{
Graphics unique=new Graphics(4, "Nvinda", 6, 7, 9, false, false, "sdf" );
System.out.println(unique);
私は正直なところあなたが何を求めているのかわかりません。 「変数を変更する」とはどういう意味ですか? 「いくつかの変数を変換する」とはどういう意味ですか? 「サービスとサポートの方法」とは何ですか? 「失敗する」とは何を意味するのかを説明し、代わりに何を見ましたか? – VGR
私はWorGamを印刷したい、そしてWaGaが真ならばWorGamは "Workstation"を、偽ならば "Gaming"を印刷する –
if文のように聞こえる。実際には、適切な変数とメソッドの命名規則を使用する必要があります。 –