-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
correct several typos in files #20
Open
huangmaomu
wants to merge
8
commits into
bethrobson:master
Choose a base branch
from
huangmaomu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d8c84c
update Amplifier.java
huangmaomu b3d889d
Update Amplifier.java
huangmaomu 4feb638
update Tuner
huangmaomu 1d82f31
remove setCd from endCd
huangmaomu 8a3ab30
create a new folder to complete the game exercise
huangmaomu 204f03f
Delete game
huangmaomu 1d57665
folder to store game package for strategy
huangmaomu 4993402
Add sample code to complete the exercise regarding strategy pattern.
huangmaomu 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 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 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 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
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/AxeBehavior.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class AxeBehavior implements WeaponBehavior { | ||
|
||
@Override | ||
public void useWeapon() { | ||
// TODO Auto-generated method stub | ||
System.out.println("chopping with an axe"); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/BowAndArrowBehavior.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class BowAndArrowBehavior implements WeaponBehavior { | ||
|
||
@Override | ||
public void useWeapon() { | ||
// TODO Auto-generated method stub | ||
System.out.println("shooting with an arrow and a bow"); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/headfirst/designpatterns/strategyPattern/game/Character.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package game1; | ||
|
||
public abstract class Character { | ||
WeaponBehavior weapon; | ||
|
||
public void setWeapon(WeaponBehavior w){ | ||
this.weapon = w; | ||
} | ||
|
||
public void performUseWeapon() { | ||
weapon.useWeapon(); | ||
} | ||
|
||
public void fight() { | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/headfirst/designpatterns/strategyPattern/game/GameStart.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package game1; | ||
|
||
public class GameStart { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
Character character1 = new Queen(); | ||
character1.performUseWeapon(); | ||
character1.fight(); | ||
|
||
Character character2 = new King(); | ||
character2.performUseWeapon(); | ||
character2.fight(); | ||
|
||
Character character3 = new Troll(); | ||
character3.performUseWeapon(); | ||
character3.fight(); | ||
|
||
Character character4 = new Knight(); | ||
character4.performUseWeapon(); | ||
character4.fight(); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/King.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class King extends Character { | ||
public King() { | ||
weapon = new SwordBehavior(); | ||
} | ||
|
||
public void fight() { | ||
System.out.println("King is fighting"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/KnifeBehavior.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class KnifeBehavior implements WeaponBehavior { | ||
|
||
public void useWeapon() { | ||
// TODO Auto-generated method stub | ||
System.out.println("cutting with a knife"); | ||
|
||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/Knight.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class Knight extends Character { | ||
public Knight() { | ||
weapon = new KnifeBehavior(); | ||
} | ||
|
||
public void fight() { | ||
System.out.println("Knight is fighting"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/headfirst/designpatterns/strategyPattern/game/Queen.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package game1; | ||
|
||
public class Queen extends Character { | ||
|
||
public Queen() { | ||
weapon = new BowAndArrowBehavior(); | ||
} | ||
|
||
public void fight() { | ||
System.out.println("Queen is fighting"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/SwordBehavior.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class SwordBehavior implements WeaponBehavior { | ||
|
||
@Override | ||
public void useWeapon() { | ||
// TODO Auto-generated method stub | ||
System.out.println("swinging a sword"); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/headfirst/designpatterns/strategyPattern/game/Troll.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package game1; | ||
|
||
public class Troll extends Character { | ||
public Troll() { | ||
weapon = new AxeBehavior(); | ||
} | ||
|
||
public void fight() { | ||
System.out.println("Troll is fighting"); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/headfirst/designpatterns/strategyPattern/game/WeaponBehavior.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package game1; | ||
|
||
public interface WeaponBehavior { | ||
public void useWeapon(); | ||
} |
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.
package name is incorrect