-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPrototypeTest.java
More file actions
36 lines (26 loc) · 1.02 KB
/
PrototypeTest.java
File metadata and controls
36 lines (26 loc) · 1.02 KB
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
31
32
33
34
35
36
package prototype;
import junit.framework.TestCase;
import org.junit.Test;
public class PrototypeTest extends TestCase {
@Test
public void test(){
System.out.println("PrototypeTest:");
System.out.println("Creating tickets...");
Ticket ticket = new Ticket(30,"2020-11-23","AdultTicket");
ticket.giftticket = new Ticket(0,"2020-11-23","GiftTicket");
System.out.println();
System.out.println("Shallow Copy...");
Ticket ticket1 = (Ticket)ticket.clone();
Ticket ticket2 = (Ticket)ticket.clone();
System.out.println();
System.out.println("Check shallow copy object:");
System.out.println(ticket1.getFormattedInfo());
System.out.println(ticket2.getFormattedInfo());
System.out.println();
System.out.println("Deep Copy...");
Ticket ticket3 = (Ticket)ticket.deepClone();
System.out.println();
System.out.println("Check deep copy object:");
System.out.println(ticket3.getFormattedInfo());
}
}