Skip to content
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
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setVolume(int level) {
}

public void setTuner(Tuner tuner) {
System.out.println(description + " setting tuner to " + dvd);
System.out.println(description + " setting tuner to " + tuner);
this.tuner = tuner;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void listenToCd(String cdTitle) {
public void endCd() {
System.out.println("Shutting down CD...");
amp.off();
amp.setCd(cd);
cd.eject();
cd.off();
}
Expand Down
1 change: 1 addition & 0 deletions src/headfirst/designpatterns/facade/hometheater/Tuner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class Tuner {

public Tuner(String description, Amplifier amplifier) {
this.description = description;
this.amplifier = amplifier;
}

public void on() {
Expand Down
11 changes: 11 additions & 0 deletions src/headfirst/designpatterns/strategyPattern/game/AxeBehavior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package game1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package name is incorrect


public class AxeBehavior implements WeaponBehavior {

@Override
public void useWeapon() {
// TODO Auto-generated method stub
System.out.println("chopping with an axe");
}

}
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 src/headfirst/designpatterns/strategyPattern/game/Character.java
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 src/headfirst/designpatterns/strategyPattern/game/GameStart.java
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 src/headfirst/designpatterns/strategyPattern/game/King.java
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");
}
}
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 src/headfirst/designpatterns/strategyPattern/game/Knight.java
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 src/headfirst/designpatterns/strategyPattern/game/Queen.java
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");
}
}
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 src/headfirst/designpatterns/strategyPattern/game/Troll.java
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");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package game1;

public interface WeaponBehavior {
public void useWeapon();
}