十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
//测试类!
义乌网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站开发等网站项目制作,到程序开发,运营维护。创新互联于2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
public class StudentTest {
public static void main(String[] args) {
//测试1:
Studen s=new Studen();//创建对象!
System.out.println(s);//测试打印对象属性!
System.out.println("\n----------------分割线------------------\n");
//测试2:
Studen s1=new Studen("张三","2017-12-07","1900/10/10","机电",100);
s1.study();
System.out.println(s1);
}
}
//学生类!
class Studen{
private String name;//姓:
private String number;//号:
private String day;//生;
private String spe;//专!
private int age;//年龄!
Studen(){//空参构造!
this("无名氏","2017-12-13","1999/10/27","本课",18);
}//形参构造!
public Studen(String name, String number, String day, String spe, int age) {
super();
this.name = name;
this.number = number;
this.day = day;
this.spe = spe;
this.age = age;
}//修改年龄!
public void setAge(int age) {
this.age = age;
}//修改出生!
public void setDay(String day) {
this.day = day;
}//修改专业!
public void setSpe(String spe) {
this.spe = spe;
}//修改姓名!
public void setName(String name) {
this.name = name;
}//修改学号!
public void setNumber(String number) {
this.number = number;
}//获取学号!
public String getNumber() {
return number;
}//获取出生!
public String getDay() {
return day;
}//获取专业!
public String getSpe() {
return spe;
}//获取年龄!
public int getAge() {
return age;
}//获取姓名!
public String getName() {
return name;
}//学习方法!
public void study() {
System.out.println(name+",在学习:"+spe);
}
public String toString() {
return "姓名:"+name+";年龄:"+age+";专业:"+spe+";学号:"+number;
}
}
public class Student {
private String sno; //学号
private String name; //姓名
private String sex; //性别
private String calss; //班级
private String major; //专业
public String getSno() {
return sno;
}
public void setSno(String sno) {
this.sno = sno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getCalss() {
return calss;
}
public void setCalss(String calss) {
this.calss = calss;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public Student() {
}
public Student(String sno, String name) {
this.sno = sno;
this.name = name;
}
public Student(String sno, String name, String sex, String calss,
String major) {
this.sno = sno;
this.name = name;
this.sex = sex;
this.calss = calss;
this.major = major;
}
,至于后面的,都是页面的东西,查询数据库啊什么的。要设计页面,我就不弄了。
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test222 {
public static void main(String[] args) throws IOException {
int i, j;
String a;
BufferedReader str = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("请输入学号:");
a = str.readLine();
System.out.println("学号为:" + a);
str = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入姓名:");
a = str.readLine();
System.out.println("姓名为:" + a);
}
}
望采纳~~