import java.util.*;
class computer{//
private String name;
private String color;
private String type;
private String ram;
private String harddisk;
private int price;
private String state;
public String open(String state){
return state;
}
public String close(String state){
return state;
}
public String hitch(String state){
return state;
}
public computer(){//默认的构造方法
name=" ";
color=" ";
type=" ";
ram=" ";
harddisk=" ";
price=0;
state=" ";
}
public computer(String tanjicong,String lan,String p4,String 1G,String hongji,int 3500,String good){//自己定义的构造方法
name="micro";
color="lan";
type="p4";
ram="1G";
harddisk="hongji";
price=3500;
state="good";
}
public String getname(){
return name;
}
public String getcolor(){
return color;
}
public String gettype(){
return type;
}
public String getram(){
return ram;
}
public String getharddisk(){
return harddisk;
}
public int getprice(){
return price;
}
public String getstate(){
return state;
}
}
public class jisuanji{//主类
public static void main(String args[]){
computer[] staff=new computer[4];
staff[1]=new computer();
staff[2]=new computer("dell","黑","pentium4","512MB","120G","3000","良好");
staff[3]=new computer("联想","黑","pentium4","256MB","80G","2000","良好");
for(int i=1;i<=3;i++)
{
computer e=staff[i];
System.out.println("计算机品牌:"+e.getname()+"计算机音色"+e.getcolor()+
"型号"+e.gettype()+"内存容量"+e.getram()+"硬盘容量"+e.getharddisk()+"价格"+e.getprice()+"工作状态"+e.getstate());
}
}
}
这个程序不难,但是就是作的不对,不知道为什么原因,老是有语法错误,各位高手帮我看看,这到底是什么原因!有劳各位拉!