用java编写一个学生类

题目:定义一个表示学生的类Student。这个类的属性有“学号”、“班号”、“姓名”、“性别”、“年龄”,方法有“获得学号”、“获得班号”、“获得性别”、“获得姓名”、“获得年龄”。

	public class Student{ 
	private int xh,code,age;
	private String name,sex;
	public Student(int xh,int code,String name,String sex,int age){
	super();
	this.xh=xh;
	this.code=code;
	this.name=name;
	this.sex=sex;
	this.age=age;
	}
	public int GetXh(){
    return xh;
	}
	public int GetCode(){
		return code;
	}
	public String GetName(){
		return name;
	}
		public String GetSex(){
			return sex;}
			public int age(){
				return age;}
			public void show(){
				System.out.println("学号: "+"班号: "+"姓名: "+"性别 : "+"年龄: ");
			}
			public static void main(String args[]){
			Student s=new Student(1818,1,"lina","女",19);
			s.xh=1818;
			s.code=1;
			s.name="lina";
			s.sex="女";
			s.age=19;
			}
			}
发布了65 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/gl620321/article/details/101670951