-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestGravBody.java
More file actions
101 lines (66 loc) · 2.87 KB
/
TestGravBody.java
File metadata and controls
101 lines (66 loc) · 2.87 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestGravBody {
@Test
public void testGetXCoord() {
GravBody gb = null; // TODO: Replace null w/ call to GravBody cons
// It is NEVER a good idea to check if floating point numbers are
// ==. To represent floating point numbers using binary, the
// computer must ROUND when it does math.
// For example, System.out.println(0.7 + 0.1 == 0.9 - 0.1);
// will print false.
//
// Instead, it's a good idea to see if floating point numbers are
// really really CLOSE. So we need to specify how close they should
// be to basically count as equal. That's this number below:
double delta = 0.00001;
assertEquals(1986.1203, gb.getXCoord(), delta);
}
@Test
public void testGetYCoord() {
GravBody gb = null; // TODO: Replace null with call to GravBody
// constructor that sets the y-value to you like
double delta = 0.00001;
// TODO: assert that gb.getYCoord() returns the y-value you picked in
// the constructor. This is exactly like testGetXCoord() above.
}
// TODO: Add a test for getXVel
// TODO: Add a test for getYVel
// TODO: Add a test for getRadius
// TODO: Add a test for getRGB
// TODO: Add a test for getMass
@Test
public void testAddForceFrom(){
// HINT: The physics coursework/homework you did is helpful here
GravBody gbA = null; // TODO: Replace null w/ call to GravBody cons
GravBody gbB = null; // TODO: Replace null w/ a call to GravBody cons
GravBody gbC = null; // TODO: Replace null w/ a call to GravBody cons
// TODO: Assert that the x and y component of force on gbA are 0
// HINT: There's no method on the Body to get the forces--but gbA is
// a GravBody. So you can add methods to gravBody that isnt' on the
// interface to get the forces you need solely for testing purposes.
gbA.addForceFrom(gbB);
gbA.addForceFrom(gbC);
// TODO: Assert that the x and y components of force on gbA are correct
// TODO: Assert that the x and y components of force on gbB are 0
gbB.addForceFrom(gbA);
gbB.addForceFrom(gbC);
// TODO: Assert that x and y components of force on gbB are correct
// TODO: Write test ensuring that forces can be calculated correctly
// for gbC
// HINT: It's the same as the last two test cases you wrote.
}
@Test
public void testMove(){
// HINT: The physics coursework/homework you did her is helpful.
// TODO: Create 3 GravBody objects
// TODO: For each GravBody object, add force from other two
// TODO: Move each GravBody object for some time delta
// TODO: For each GravBody object, assert that new x and y coordinates
// are correct after movement
// TODO: For each GravBody object, assert that x and y components of
// force are now 0
// TODO: Repeat the above process on the same 3 GravBody objects once
// more.
}
}