-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComposite.java
82 lines (63 loc) · 1.47 KB
/
Composite.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
import java.util.Scanner;
public class Composite extends Polyhedron {
/**
* Collection of polyhedra of which
* this composite polyhedron is composed
*/
private Polyhedron[] polyhedra;
/**
* Default Constructor
*/
Composite()
{
super("Composite");
polyhedra = null;
}
/**
* Copy Constructor
*/
Composite(Composite src)
{
super("Composite");
// Start with copy code
// do not forget to check if
// polyhedra is null
}
/**
* Read all component polyhedra
*
* @pre polyhedra == null
* && numPolyhedra == 0
*/
public void read(Scanner scanner)
{
int numPolyhedra = scanner.nextInt();
polyhedra = new Polyhedron[numPolyhedra];
for (int i = 0; i < polyhedra.length; i++) {
polyhedra[i] = Polyhedron.createAndRead(scanner);
boundingBox.merge(polyhedra[i].getBoundingBox());
}
}
public Polyhedron clone()
{
return new Composite(this);
}
public void scale(double scalingFactor)
{
// loop
}
/**
* Scale all polyhedra
*/
public String toString()
{
StringBuilder bld = new StringBuilder();
bld.append(super.toString());
// Start your toString code here
//end your toString code here
return bld.toString();
}
}