我必须能够在一定变量转换在我的课。我有一个布尔变量,WaGa(代表工作站/游戏电脑),如果它是真的,我想转换字符串WorGam如何改变一个变量,在一个Java类
我必须通过服务和支持方法来做到这一点,我一直试图,但我坚持失败。它只是打印出驱动程序中的内容。帮帮我。
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,如果贺是真的,那么WorGam打印“工作站”,如果假的,它打印“游戏” –
听起来就像if语句。你真的应该使用适当的变量和方法命名约定。 –