|
查看: 1278|回复: 7
|
大家。。可以帮我看下这JAVA CODE 有问题吗?
[复制链接]
|
|
|
我这是OBEJECT ORIENTATED PROGRAMMING。。。
现有两个CLASS。。。
public class Name implements Cloneable{
private String firstName;
private char mi;
private String lastname;
public Name(){
this("e",'s',"Mn" );
}
public Name(String firstName,char mi,String lastname){
this.firstName=firstName;
this.mi=mi;
this.lastname=lastname;
}
public String getfirstName(){
return firstName;
}
public void setfirstName(String firstName){
this.firstName=firstName;
}
public char getmi(){
return mi;
}
public void setmi(char mi){
this.mi=mi;
}
public String getlastname(){
return lastname;
}
public void setlastname(){
this.lastname=lastname;
}
public String getFullName(){
return firstName+" "+mi+" "+lastname ;
}
}
public class Person /*implements Comparable*/ {
private Name name;
}
public Person(){
this(new Name("e",'s'," mn" );
}
public Person(Name name){
this.name=name;
}
public Name getname(){
return name;
}
public void setname(){
this.name=name;
}
public String toString(){
return "Name:"+name.getFullName();
}
command result 出现:class,interface,or enum expected
public Person(){
^
10 errors象这样的...
我看了很久 了。。。。才ASSIGNEMNT 的开端罢了
[ 本帖最后由 不平凡人生 于 22-7-2008 11:57 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 23-7-2008 08:01 AM
|
显示全部楼层
|
我太差了,看不出什么问题,你的两个class是分开的吗? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-7-2008 11:10 AM
|
显示全部楼层
回复 2# FeoFeona 的帖子
对,就两个。。。没问题吧我的CODE。。
是我JAVA SETTING 的问题吗? |
|
|
|
|
|
|
|
|
|
|
发表于 23-7-2008 11:17 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 23-7-2008 11:27 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 23-7-2008 12:03 PM
|
显示全部楼层
括弧问题
分成两个CLASS
public class Name implements Cloneable {
private String firstName;
private char mi;
private String lastname;
public Name() {
this("e", 's', "Mn");
}
public Name(String firstName, char mi, String lastname) {
this.firstName = firstName;
this.mi = mi;
this.lastname = lastname;
}
public String getfirstName() {
return firstName;
}
public void setfirstName(String firstName) {
this.firstName = firstName;
}
public char getmi() {
return mi;
}
public void setmi(char mi) {
this.mi = mi;
}
public String getlastname() {
return lastname;
}
public void setlastname() {
this.lastname = lastname;
}
public String getFullName() {
return firstName + " " + mi + " " + lastname;
}
}
====================================================================
public class Person /*implements Comparable*/ {
private Name name;
public Person(){
this(new Name("e",'s'," mn"));
}
public Person(Name name){
this.name=name;
}
public Name getname(){
return name;
}
public void setname(){
this.name=name;
}
public String toString(){
return "Name:"+name.getFullName();
}
} |
|
|
|
|
|
|
|
|
|
|
发表于 23-7-2008 03:31 PM
|
显示全部楼层
|
原来是Person这个Class没有刮弧包住其他class内method。。。。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-7-2008 08:21 PM
|
显示全部楼层
真的很感谢。。。我搞定了。。。
真的要打屁股了。。是刮弧问题 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|