Skip to content

Commit

Permalink
updates for 2nd ed
Browse files Browse the repository at this point in the history
  • Loading branch information
bethrobson committed Aug 21, 2020
1 parent 0162a60 commit 8bac880
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/headfirst/designpatterns/factory/pizzas/Pizza.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package headfirst.designpatterns.factory.pizzas;

import java.util.ArrayList;
import java.util.*;

abstract public class Pizza {
String name;
String dough;
String sauce;
ArrayList<String> toppings = new ArrayList<String>();
List<String> toppings = new ArrayList<String>();

public String getName() {
return name;
Expand Down
2 changes: 2 additions & 0 deletions src/headfirst/designpatterns/observer/simple/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ public static void main(String[] args) {
SimpleObserver simpleObserver = new SimpleObserver(simpleSubject);

simpleSubject.setValue(80);

simpleSubject.removeObserver(simpleObserver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ public void registerObserver(Observer o) {
}

public void removeObserver(Observer o) {
int i = observers.indexOf(o);
if (i >= 0) {
observers.remove(i);
}
observers.remove(o);
}

public void notifyObservers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public void registerObserver(Observer o) {
}

public void removeObserver(Observer o) {
int i = observers.indexOf(o);
if (i >= 0) {
observers.remove(i);
}
observers.remove(o);
}

public void notifyObservers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ public static void main(String[] args) {
weatherData.setMeasurements(80, 65, 30.4f);
weatherData.setMeasurements(82, 70, 29.2f);
weatherData.setMeasurements(78, 90, 29.2f);

weatherData.removeObserver(forecastDisplay);
weatherData.setMeasurements(62, 90, 28.1f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void paintIcon(final Component c, Graphics g, int x, int y) {
g.drawString("Loading album cover, please wait...", x+300, y+190);
if (!retrieving) {
retrieving = true;
/*

retrievalThread = new Thread(new Runnable() {
public void run() {
try {
Expand All @@ -50,7 +50,7 @@ public void run() {
}
}
});
*/

retrievalThread = new Thread(() -> {
try {
setImageIcon(new ImageIcon(imageURL, "Album Cover"));
Expand All @@ -60,7 +60,7 @@ public void run() {
}
});
retrievalThread.start();

}
}
}
Expand Down

0 comments on commit 8bac880

Please sign in to comment.