Repository navigation
Step6 pr 보냅니다. #119
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
Merged
Merged
Step6 pr 보냅니다. #119
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b1f8593
merge test
jar100 6cf70c1
step5 make Figure class
jar100 76076aa
HashSet refactoring
jar100 e62874d
step5 refectoring
jar100 33e8ec1
step6 수정
jar100 8620815
merge test
jar100 f577352
step6 merge
jar100 8f64d01
step6 java convention repectoring
jar100 a451905
step6 feedback refactoring
jar100 a382466
상속 피드백 반영
jar100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,46 @@ | ||
| package coordinate.domain; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public abstract class AbstractFigure implements Figure{ | ||
| protected ArrayList<Point> points; | ||
| public abstract class AbstractFigure implements Figure { | ||
| private List<Point> points; | ||
|
|
||
| public AbstractFigure(ArrayList<Point> points) { | ||
| AbstractFigure(List<Point> points) { | ||
| this.points = points; | ||
| figureException(); | ||
| } | ||
|
|
||
| private Boolean isSamePoint() { | ||
| HashSet<Point> isTrue = new HashSet<>(points); | ||
| Set<Point> isTrue = new HashSet<>(points); | ||
| return isTrue.size() == this.points.size(); | ||
| } | ||
|
|
||
| public String result() { | ||
| private void figureException() { | ||
| if (this.points.size() < size()) { | ||
| return name() + "이 아닙니다."; | ||
| throw new IllegalArgumentException(name() + "이 아닙니다. 다시 입력 해주세요"); | ||
| } | ||
| if (!isSamePoint()) { | ||
| throw new IllegalArgumentException("같은 점을 입력했습니다. " + name() + "이 아닙니다. 다시 입력해 주세요"); | ||
| } | ||
| if (!isFigure()) { | ||
| throw new IllegalArgumentException(name() + "이 아닙니다. 다시 입력 해주세요"); | ||
| } | ||
| return name()+ "의 면적은 " + area() + " 입니다."; | ||
| } | ||
|
|
||
| protected boolean isFigure() { | ||
| return true; | ||
| } | ||
|
|
||
| protected abstract String name(); | ||
|
|
||
| protected abstract int size(); | ||
|
|
||
| protected Point getPoint(int index) { | ||
| return points.get(index); | ||
| } | ||
|
|
||
| protected List<Point> getPoints() { | ||
| return points; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package coordinate.domain; | ||
|
|
||
| public interface Figure { | ||
| String name(); | ||
|
|
||
| double area(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| package coordinate.domain; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public interface FigureCreator { | ||
| AbstractFigure create(ArrayList<Point> points); | ||
| Figure create(List<Point> points); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package coordinate.domain; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class LineFactory implements FigureCreator { | ||
| @Override | ||
| public AbstractFigure create(ArrayList<Point> points) { | ||
| public AbstractFigure create(List<Point> points) { | ||
| return new Line(points); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package coordinate.domain; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class RectangleFactory implements FigureCreator { | ||
| @Override | ||
| public AbstractFigure create(ArrayList<Point> points) { | ||
| public AbstractFigure create(List<Point> points) { | ||
| return new Rectangle(points); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
figureException() 처리를 이 생성자에서 처리하도록 구현하고 자식 생성자에서 figureException()를 호출하지 않도록 구현해 본다.