java 程序问题 急!!!!!!!!
来源:百度知道 编辑:UC知道 时间:2024/07/04 01:10:17
public class Student {
//学号固定部分,此处定义为常量
private final static String stuNum = "2010030";
//学号尾数
private static int stuCode;
//学生姓名
private String name; //姓名
//构造函数,初始化对象的name属性,并将静态变量stuCode自增
public Student(String name){
this.name = name;
stuCode++;
}
//将静态变量学号尾数转换为字符串并返回
public static String getStuCode(){
return Integer.toString(stuCode) + ;
}
//获得学生信息,此处增加了参数为Student对象(目的是灵活)
public String showInfo(Student student){
String stuInfo = "姓名:" + student.name + " " + "学号:" + stuNum+stuCode;
return stuInfo;
}
//主函数
public static void main(String argc[]){
Student stu1 = new Student("张三");
System.out.println(stu1.showInfo(stu1));
Student stu2 = new Student("李四");
System.out.println(stu2.showInf