-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserOfCopyConstructor.java
More file actions
54 lines (46 loc) · 1.96 KB
/
UserOfCopyConstructor.java
File metadata and controls
54 lines (46 loc) · 1.96 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
test copy constructor for BoardForQueensPuzzle
*/
public class UserOfCopyConstructor {
public static void main(String[] commandLine) {
System.out.println();
System.out.println(
"Code in the skeleton for BoardForQueensPuzzle was tested "
+ "in the previous homework." + System.lineSeparator()
+ "Code below here tests the copy constructor in "
+ "BoardForQueensPuzzle." + System.lineSeparator()
);
// Create the board that will be changed
BoardForQueensPuzzle changeMe = new BoardForQueensPuzzle( 3);
changeMe.populate(2);
changeMe.populate(0);
System.out.println( "Before change, the original is..."
+ System.lineSeparator()
+ changeMe
);
// copy-construct another board
BoardForQueensPuzzle snapshot = new BoardForQueensPuzzle( changeMe);
System.out.println( "...and the snapshot is..."
+ System.lineSeparator()
+ snapshot
);
// shrink the original
changeMe.depopulate();
System.out.println( "after depopulation, the original is..."
+ System.lineSeparator()
+ changeMe + System.lineSeparator()
+ "...and the snapshot is..."
+ System.lineSeparator()
+ snapshot
);
// re-populate the original, but into a different file
changeMe.populate(1);
System.out.println( "after re-population, the original is..."
+ System.lineSeparator()
+ changeMe + System.lineSeparator()
+ "...and the snapshot is..."
+ System.lineSeparator()
+ snapshot
);
}
}