Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person {
- private int weight;
- private int age;
- private String name;
- private String pesel;
- public Person() {};
- public Person(String name) {
- this.name = name;
- }
- public Person(int weight, int age, String name, String pesel) {
- this.weight = weight;
- this.age = age;
- this.name = name;
- this.pesel = pesel;
- }
- public int getAge() {
- return age;
- }
- public String getPesel() {
- return pesel;
- }
- public int getWeight() {
- return weight;
- }
- public String getName() {
- return name;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public void setPesel(String pesel) {
- this.pesel = pesel;
- }
- public void setWeight(int weight) {
- this.weight = weight;
- }
- public void setName(String name) {
- this.name = name;
- }
- //w pozniejszym etapie nauki zamienic + na StringBuilder i wygooglowac: "Why use stringbuilder instead of + in java?"
- @Override
- public String toString() {
- return "Imie: " + name + ", wiek: " + age + ", waga: " + weight + ", PESEL: " + pesel;
- }
- @Override
- public boolean equals(Object obj) {
- if (obj == null)
- return false;
- else if (obj instanceof Person) {
- Person other = (Person) obj;
- return pesel.equals(other.pesel);
- } else
- return false;
- }
- @Override
- public int hashCode() {
- return pesel.hashCode();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement