-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Step5 #5836
base: sweet-info
Are you sure you want to change the base?
Step5 #5836
Changes from all commits
d052c02
174573b
615bf67
6186238
386e458
090df7a
72f03e5
5eef038
759b277
0e66676
c7ba287
b2ee0e6
7a715fa
e4579df
e0d896f
3e30641
d9837d2
fb069c0
1f94e5b
caeac4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package racing; | ||
|
||
import racing.controller.CarRacingController; | ||
|
||
public class RacingApplication { | ||
public static void main(String[] args) { | ||
CarRacingController.main(args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ public static void main(String[] args) { | |
} | ||
resultView.findWinners(cars.findWinners()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ public int getValue() { | |
public Position movePosition() { | ||
return new Position(value + 1); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,3 @@ public List<Car> findWinners() { | |
.filter(car -> car.isPosition(maxPosition)) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package racing; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import racing.entity.CarName; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class CarNameTest { | ||
|
||
@Test | ||
void carNameIsSetCorrectly() { | ||
CarName carName = new CarName("Car"); | ||
assertEquals("Car", carName.getValue()); | ||
} | ||
|
||
@Test | ||
void carNameCannotBeNull() { | ||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assertThrows(IllegalArgumentException.class, () -> new CarName(null)); | ||
} | ||
|
||
@Test | ||
void carNameCannotBeEmpty() { | ||
assertThrows(IllegalArgumentException.class, () -> new CarName("")); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ void carDoesNotMove() { | |
Car car = new Car("Car") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@Override | ||
public void move() { | ||
if (canMove(5)) { // 임의의 값 5를 전달하여 항상 true를 반환하도록 함 | ||
|
||
if (canMove(5)) { | ||
|
||
Position position = new Position(1); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package racing; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import racing.entity.Position; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class PositionTest { | ||
|
||
@Test | ||
void positionCorrectly() { | ||
Position position = new Position(5); | ||
assertEquals(5, position.getValue()); | ||
} | ||
|
||
@Test | ||
void positionCannotBeNegative() { | ||
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new Position(-1)); | ||
assertEquals("cannot be negative.", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
void movePositionCorrectly() { | ||
Position position = new Position(5); | ||
Position movedPosition = position.movePosition(); | ||
assertEquals(6, movedPosition.getValue()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
와 같은 숫자 리터럴은 상수로 선언하여 의미를 부여해보면 어떨까요?