package com.yanyu;
import java.util.Objects;
public class Student {
private String name;
private int no;
private int age;
private String addr;
public Student(){
}
public Student(String name,int no, int age, String addr){
this.name = name;
this.no = no;
this.age = age;
this.addr = addr;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddr() {
return addr;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return no == student.no && age == student.age && name.equals(student.name) && addr.equals(student.addr);
}
@Override
public int hashCode() {
return Objects.hash(name, no, age, addr);
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", no=" + no +
", age=" + age +
", addr='" + addr + '\'' +
'}';
}
public void setAddr(String addr) {
this.addr = addr;
}
public void xuexi(){
System.out.println("学习");
}
public void student(String name){
System.out.println(name + "学习");
}
public void call(String name){
System.out.println(name +"打电话");
}
public void game(String name){
System.out.println(name +"游戏");
}
}
class Test {
public static void main(String[] args) {
Student student = new Student("yanyu", 101, 20, "东莞");
System.out.println("姓名:\t" + student.getName());
System.out.println("年龄:\t" + student.getAge());
System.out.println("学号:\t" + student.getNo());
System.out.println("地址:\t" + student.getAddr());
student.call(student.getName());
student.student(student.getName());
student.game(student.getName());
}
}
软件一班04
最新推荐文章于 2024-09-03 20:17:53 发布