Commit 6ae39205 authored by Jiawei Wang's avatar Jiawei Wang
Browse files

initial commit

parent 76affa1e
public class Animal {
private String name;
public Animal(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Animal [name=" + name + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Animal other = (Animal) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
......@@ -92,3 +92,4 @@ public class Book {
}
}
public class Student {
private String name;
private String gender;
private String CountryOfCitizenship;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((CountryOfCitizenship == null) ? 0 : CountryOfCitizenship.hashCode());
result = prime * result + ((gender == null) ? 0 : gender.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Student other = (Student) obj;
if (CountryOfCitizenship == null) {
if (other.CountryOfCitizenship != null)
return false;
} else if (!CountryOfCitizenship.equals(other.CountryOfCitizenship))
return false;
if (gender == null) {
if (other.gender != null)
return false;
} else if (!gender.equals(other.gender))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "Student [name=" + name + ", gender=" + gender + ", CountryOfCitizenship=" + CountryOfCitizenship + "]";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getCountryOfCitizenship() {
return CountryOfCitizenship;
}
public void setCountryOfCitizenship(String countryOfCitizenship) {
CountryOfCitizenship = countryOfCitizenship;
}
public Student(String name, String gender, String countryOfCitizenship) {
super();
this.name = name;
this.gender = gender;
CountryOfCitizenship = countryOfCitizenship;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment