-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.java
30 lines (28 loc) · 912 Bytes
/
Person.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.practice.Java;
public class Person implements Cloneable{
String name;
int age;
Stats stats;
public Person(String name, int age, Stats stats) {
this.age = age;
this.name = name;
this.stats = stats;
}
@Override
public Person clone() throws CloneNotSupportedException {
Person person = (Person) super.clone();
person.stats = (Stats) stats.clone();
return person;
}
public void printAll() {
System.out.println("name: " + this.name);
System.out.println("age: " + this.age);
System.out.println("Stats: ");
System.out.print(" ");
System.out.println("height: " + this.stats.height);
System.out.print(" ");
System.out.println("weight: " + this.stats.weight);
System.out.print(" ");
System.out.println("gender: " + this.stats.gender);
}
}