-
Notifications
You must be signed in to change notification settings - Fork 3
박우빈 백엔드 과제 제출합니다. #3
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
base: ubinquitous
Are you sure you want to change the base?
Changes from all commits
9840f1d
b93552c
5766a80
2823bf9
7855396
ccb4a34
5ec4a91
4fc9eb9
5f61bb0
27250ea
5651a08
6400309
4d932d5
db8af80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| soccer game middle | ||
|
|
||
| Player { | ||
| name ( VO ) | ||
| final static Integer chance | ||
| } | ||
|
|
||
| Attacker Extends Player { | ||
| Integer goals | ||
|
|
||
| shoot ( ) | ||
| } | ||
|
|
||
| Striker extends Attacker { | ||
| chance = 2 | ||
| } | ||
|
|
||
| Midfielder extends Attacker { | ||
| chance = 1 | ||
|
|
||
| shoot ( ) | ||
| } | ||
|
|
||
| GoalKeeper extends Player { | ||
| chance = 3 | ||
|
|
||
| saves ( 3 ~ 7 ) | ||
| } | ||
|
|
||
| SoccerGame { | ||
| winner | ||
| List<Attacker> attackers; | ||
| GoalKeeper goalkeeper; | ||
| final matchpoint = 0; | ||
| final Winner winner; | ||
|
|
||
| init(){ | ||
| settingPlayer() | ||
| } | ||
|
|
||
| setMatchPoint() { | ||
| matchpoint = set | ||
| } | ||
|
|
||
| start(){ | ||
| while(matchpoint != 0) { | ||
| shooting() | ||
| checkMatch() | ||
| printshooting() | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| printshooting(){ | ||
|
|
||
| } | ||
|
|
||
| shootings () { | ||
| forEach Attackers { | ||
| checkGoals() | ||
| checkMatchPoints() | ||
| } | ||
| } | ||
|
|
||
| checkMatchPoints() { | ||
| if matchpoint == goals { | ||
| winner = name | ||
| } | ||
| } | ||
|
|
||
| checkGoals(Attackers) { | ||
| shoot = [ ] | ||
| for attackers.shoot | ||
| goalkeepr.keep | ||
|
|
||
| if shoot != keep { | ||
| attackers.goal() | ||
| } | ||
| } | ||
|
|
||
| setMatchPoint( matchpoint ){ this.matchpoint = matchpoint } | ||
|
|
||
| setting { | ||
| setStriker() | ||
| setMidfielder() | ||
| setGoalkeeper() | ||
| } | ||
|
|
||
| set … { | ||
| input(“입력”) | ||
| new | ||
|
|
||
| attackers add | ||
| } | ||
|
|
||
| setGoalkeeper { | ||
| goalkeeper = new GoalKeeper(“오예스”); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| import game.SoccerGameController; | ||
|
|
||
| public class SoccerGameApplication { | ||
| public static void main(String[] args) { | ||
|
|
||
| SoccerGameController soccerGameController = new SoccerGameController(); | ||
| soccerGameController.start(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package entity; | ||
|
|
||
| import vo.Name; | ||
| import vo.Winner; | ||
|
|
||
| public abstract class Attacker extends Player { | ||
| private Integer goals = 0; | ||
|
Member
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. 개행이 필요할 것 같아요! |
||
| public Attacker(String name, Integer chance) { | ||
| super(name, chance); | ||
| } | ||
|
|
||
| public Integer shoot(){ | ||
| return (int)(Math.random()*10); | ||
| } | ||
|
|
||
| public Integer getGoals() { | ||
| return goals; | ||
| } | ||
|
|
||
| public void addGoals() { | ||
| goals += 1; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package entity; | ||
|
|
||
| import vo.Name; | ||
|
|
||
| public class GoalKeeper extends Player{ | ||
| public GoalKeeper(String name) { | ||
|
Member
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. 전체적으로 개행 신경써주세요! |
||
| super(name, 3); | ||
| } | ||
|
|
||
| public Integer saves() { | ||
| return (int)(Math.random()*10); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package entity; | ||
|
|
||
| import vo.Name; | ||
|
|
||
| public class Midfielder extends Attacker{ | ||
|
|
||
| public Midfielder(String name) { | ||
| super(name, 1); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package entity; | ||
|
|
||
| import vo.Name; | ||
| import vo.Winner; | ||
|
|
||
| public class Player { | ||
| private Name name; | ||
| private Integer chance = 0; | ||
|
|
||
| public Player(String name, Integer chance) { | ||
| this.name = new Name(name); | ||
| this.chance = chance; | ||
| } | ||
|
|
||
| public Name getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public Integer getChance() { | ||
| return chance; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package entity; | ||
|
|
||
| import vo.Name; | ||
|
|
||
| public class Striker extends Attacker { | ||
| public Striker(String name) { | ||
| super(name, 2); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package game; | ||
|
|
||
| import entity.Attacker; | ||
| import entity.GoalKeeper; | ||
| import vo.Name; | ||
| import vo.Winner; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class SoccerGameController { | ||
| private Winner winner; | ||
| private Integer currentpoint = 0; | ||
| private SoccerGameManager soccerGameManager = new SoccerGameManager(); | ||
| private SoccerGameLogger soccerGameLogger = new SoccerGameLogger(); | ||
| private SoccerGameScoreManager soccerGameScoreManager = new SoccerGameScoreManager(); | ||
| private void shooting() { | ||
| for(Attacker attacker : soccerGameManager.getAttackers()){ | ||
| soccerGameScoreManager.tryGoal(attacker, soccerGameManager.getGoalKeeper()); | ||
| updateCurrentPoints(attacker); | ||
| } | ||
| } | ||
|
|
||
| private void updateCurrentPoints(Attacker attacker){ | ||
| if(currentpoint < attacker.getGoals()){ | ||
| currentpoint = attacker.getGoals(); | ||
| setWinner(attacker.getName()); | ||
| } | ||
| } | ||
|
|
||
| private void setWinner(Name name) { | ||
| this.winner = new Winner(name.getName()); | ||
| } | ||
|
|
||
| public void start() { | ||
| soccerGameManager.init(); | ||
|
|
||
| Integer cnt = 1; | ||
| while(soccerGameManager.getMatchpoint() > currentpoint){ | ||
| shooting(); | ||
| soccerGameLogger.printShooting(soccerGameManager.getAttackers(), cnt++); | ||
|
Member
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. 전체적으로 메서드에 필요없는 값을 전달하고 있는 경우가 있는 것 같아요! |
||
| } | ||
| soccerGameLogger.printWinner(winner); | ||
| } | ||
| } | ||
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.
goal을 객체로 비교할게 아니라면 int로 사용해도 되지 않을까요?