Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nguyen Nguyen
babaisus
Commits
131f7613
Commit
131f7613
authored
May 19, 2021
by
Yuhan Chen
Browse files
Refactored and Tested
parent
96ac27f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/Rule/DemoRuleTwo.java
View file @
131f7613
...
...
@@ -41,6 +41,8 @@ public class DemoRuleTwo {
public
static
Stop
stopObj
=
new
Stop
(
280
,
200
);
public
static
ArrayList
<
Wall
>
wallObjs
=
new
ArrayList
<
Wall
>(
20
);
public
DemoRuleTwo
()
{}
//Generate Rule.Wall objects
public
static
void
setWallObjs
(
ArrayList
<
Wall
>
wallObjs
)
{
for
(
int
i
=
0
;
i
<
800
;
i
+=
40
)
{
...
...
src/test/java/Rule/DemoRuleOneTest.java
deleted
100644 → 0
View file @
96ac27f4
package
Rule
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
class
DemoRuleOneTest
{
private
static
Wall
wallTest
=
new
Wall
(
0
,
0
);
private
static
Rock
rockTest
=
new
Rock
(
40
,
80
);
private
static
Baba
babaTest
=
new
Baba
(
80
,
80
);
private
static
Is
isTest
=
new
Is
(
80
,
40
);
private
static
Win
winObj
=
new
Win
(
80
,
120
);
@Test
void
atObjectLocation
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
wallTest
);
assertEquals
(
DemoRuleOne
.
babaObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
babaObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectRight
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
babaTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectLeft
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
rockTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectUp
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
isTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectDown
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
winObj
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
}
\ No newline at end of file
src/test/java/Rule/DemoRuleThreeTest.java
deleted
100644 → 0
View file @
96ac27f4
package
Rule
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
DemoRuleThreeTest
{
private
static
Wall
wallTest
=
new
Wall
(
0
,
0
);
private
static
Rock
rockTest
=
new
Rock
(
40
,
80
);
private
static
Baba
babaTest
=
new
Baba
(
80
,
80
);
private
static
Is
isTest
=
new
Is
(
80
,
40
);
private
static
Win
winObj
=
new
Win
(
80
,
120
);
@Test
void
atObjectLocation
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
wallTest
);
assertEquals
(
DemoRuleOne
.
babaObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
babaObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectRight
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
babaTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectLeft
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
rockTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectUp
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
isTest
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
@Test
void
nearObjectDown
()
{
GeneralObject
rtnObj
=
DemoRuleOne
.
atObjectLocation
(
winObj
);
assertEquals
(
DemoRuleOne
.
isObj
.
getX
(),
rtnObj
.
getX
());
assertEquals
(
DemoRuleOne
.
isObj
.
getY
(),
rtnObj
.
getY
());
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment