| 发表于:2007-07-30 15:16:48 楼主 |
这个题的题目是: 设计一个类,分别设计3个method,第一个可以输入自己的名字和性别,第二个可以输入 自己的生日的电话,最后可以将所有的数据输出出来 下面是我自己编的,由于初学,所以还是个菜鸟,编译了一下,存在很多错误,请大家给指正一下,应该怎么编啊 class cperson { private string name; private string sex; private string bithnum; public void input() throws ioexception { string na,se; bufferedreader buf; buf=new bufferedreader(new inputstreamreader(system.in)); system.out.print( "input the name: "); na=buf.readline(); name=na; system.out.print( "input the sex: "); se=buf.readline(); sex=se; } public void inputbn() throws ioexception { string bn; bufferedreader buf; buf=new bufferedreader(new inputstreamreader(system.in)); system.out.print( "input the number: "); bn=buf.readline(); bithnum=bn; } public void output() { system.out.println( "name= "+name+ ",sex= "+sex+ ",bithnum= "+bithnum); } } public class app8_5 { public static void main(string args[]) throws ioexception { cpreson per=new cperson(); per.input(); per.inputbn(); per.output(); } } |
|
|
|
|