[java]代码库
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
String name = scan.next();
int age = scan.nextInt();
String se = scan.next();
Teacher t1 = new Teacher(num,name,age,se);
num = scan.nextInt();
name = scan.next();
age = scan.nextInt();
se = scan.next();
Teacher t2 = new Teacher(num,name,age,se);
System.out.println(t1.toString());
System.out.println(t2.toString());
System.out.println(t1.equals(t2));
scan.close();
}
}
class Teacher
{
int no;
int age;
String name;
String seminary;
public Teacher(int n, String na, int a, String s)
{
no = n;
name = na;
age = a;
seminary = s;
}
void setno(int n)
{
no = n;
}
void setname(String n)
{
name = n;
}
void setage(int a)
{
age = a;
}
void setseminary(String s)
{
seminary = s;
}
int getno()
{
return no;
}
int getage()
{
return age;
}
String getname()
{
return name;
}
String getseminary()
{
return seminary;
}
boolean equals(Teacher t)
{
if(this.no == t.getno())
return true;
else
return false;
}
public String toString()
{
return "no: "+no+", name:"+name+", age: "+age+", seminary: "+seminary;
}
}