类与对象
来源:互联网 发布:ubuntu重启网卡 编辑:程序博客网 时间:2024/06/06 15:02
package students;
public class Student {
String Name;
String Address;
String Degree_name;
String Department;
int Year_Commenced;
static int STUDENT_ID_BASE=901000;
static int nextID=0;
int studentID;
String getName()
{
return Name;
}
String getAddress()
{
return Address;
}
String getDegree_name()
{
return Degree_name;
}
int getYear_Commenced()
{
return Year_Commenced;
}
public void setName(String Name)
{
this.Name=Name;
}
public void setAddress(String address)
{
this.Address=address;
}
public void setDegree_name(String Degree_name)
{
this.Degree_name=Degree_name;
}
public void setDepartment(String Department)
{
this.Department=Department;
}
public void setYear_Commenced(int Year_Commenced)
{
this.Year_Commenced=Year_Commenced;
}
public String toString()
{
return "Name: "+this.Name+" Department:"+this.Department+"Year Commenced:"+this.Year_Commenced+studentID;
}
//initial student
public Student()
{
this.Name="wang";
this.Address="Caberra";
this.Degree_name="computer";
this.Department="anu";
this.Year_Commenced=2016;
}
public Student(String name)
{ this();
this.Name=name;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public Student(String name, String address)
{
this();
this.Address=address;
this.Name=name;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public Student(String name, String address, String department)
{
this();
this.Name=name;
this.Department=department;
this.Address=address;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public static void main(String[] args)
{
Student m = new Student("wangzhifeng", "22", "anu");
Student n= new Student("wangzhifng");
Student j= new Student("wangzhifen", "unsw");
Student mm = new Student("wangzhifeng", "anu", "au");
System.out.println(m.toString());
System.out.println(n.toString());
System.out.println(j.toString());
System.out.println(mm.toString());
}
}
public class Student {
String Name;
String Address;
String Degree_name;
String Department;
int Year_Commenced;
static int STUDENT_ID_BASE=901000;
static int nextID=0;
int studentID;
String getName()
{
return Name;
}
String getAddress()
{
return Address;
}
String getDegree_name()
{
return Degree_name;
}
int getYear_Commenced()
{
return Year_Commenced;
}
public void setName(String Name)
{
this.Name=Name;
}
public void setAddress(String address)
{
this.Address=address;
}
public void setDegree_name(String Degree_name)
{
this.Degree_name=Degree_name;
}
public void setDepartment(String Department)
{
this.Department=Department;
}
public void setYear_Commenced(int Year_Commenced)
{
this.Year_Commenced=Year_Commenced;
}
public String toString()
{
return "Name: "+this.Name+" Department:"+this.Department+"Year Commenced:"+this.Year_Commenced+studentID;
}
//initial student
public Student()
{
this.Name="wang";
this.Address="Caberra";
this.Degree_name="computer";
this.Department="anu";
this.Year_Commenced=2016;
}
public Student(String name)
{ this();
this.Name=name;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public Student(String name, String address)
{
this();
this.Address=address;
this.Name=name;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public Student(String name, String address, String department)
{
this();
this.Name=name;
this.Department=department;
this.Address=address;
this.nextID=this.nextID+1;
this.studentID=this.STUDENT_ID_BASE+this.nextID;
}
public static void main(String[] args)
{
Student m = new Student("wangzhifeng", "22", "anu");
Student n= new Student("wangzhifng");
Student j= new Student("wangzhifen", "unsw");
Student mm = new Student("wangzhifeng", "anu", "au");
System.out.println(m.toString());
System.out.println(n.toString());
System.out.println(j.toString());
System.out.println(mm.toString());
}
}
0 0
- OOP-----类与对象对象
- OOP-----类与对象对象
- 对象与元类对象
- 对象与类类型
- C02(类与对象)
- 类与对象(PHP5)
- 类与对象
- 区分类与对象
- 类与对象
- 类与对象
- 类与对象
- C#类与对象
- 对象与类
- 类与对象总结
- js类与对象
- C++ 类与对象
- 类与对象
- 类与对象概述
- 几种 ETL 工具的比较(Kettle,Talend,Informatica 等)
- ETL利器Kettle实战应用解析系列二 【应用场景和实战DEMO下载】
- 求职谈薪水,破除锚定效应拿下高薪
- glide:自定义变换
- glide:用animate()定制动画
- 类与对象
- glide:整合网络协议栈
- glide:用Modules定制Glide
- 149. Max Points on a Line
- glide:Glide Module 案例: 接受自签名HTTPS证书
- glide:Glide Module案例: 自定义缓存
- glide:Glide Module 案例: 通过加载自定义大小图片优化
- 一些数论知识(不定期更新)
- 面向对象-final关键字