Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'uefa/master'
- Loading branch information
Showing
16 changed files
with
404 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.class | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>OOAD</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
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 @@ | ||
/com/ |
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,29 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
|
||
public enum Builder { | ||
|
||
FENDER, MARTIN, GIBSON, COLLINGS, OLSON, RYAN, PRS, ANY; | ||
|
||
public String toString() { | ||
switch(this) { | ||
case FENDER: | ||
return "Fender"; | ||
case MARTIN: | ||
return "Martin"; | ||
case GIBSON: | ||
return "Gibson"; | ||
case COLLINGS: | ||
return "Collings"; | ||
case OLSON: | ||
return "Olson"; | ||
case RYAN: | ||
return "Ryan"; | ||
case PRS: | ||
return "Prs"; | ||
case ANY: | ||
return "Any"; | ||
default: | ||
return "none"; | ||
} | ||
} | ||
} |
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,40 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
|
||
public class FindGuitarTester { | ||
|
||
public static void main(String[] args) { | ||
// 릭의 기타 재고 목록 셋업(초기화) | ||
Inventory inventory = new Inventory(); | ||
initializeInventory(inventory); | ||
|
||
GuitarSpec whatErinLikes = new GuitarSpec(Builder.FENDER, "Stratocaster", Type.ELECTRIC, 12, Wood.ALDER, Wood.ALDER); | ||
|
||
List<Guitar> matchingGuitars = inventory.search(whatErinLikes); | ||
if (!matchingGuitars.isEmpty()) { | ||
System.out.println("Erin, you might like these guitars:"); | ||
for (Iterator<Guitar> i = matchingGuitars.iterator(); i.hasNext(); ) { | ||
Guitar guitar = (Guitar)i.next(); | ||
GuitarSpec spec = guitar.getSpec(); | ||
System.out.println(" We have a " + | ||
spec.getBuilder() + " " + spec.getModel() + " " + | ||
spec.getType() + " guitar:\n " + | ||
spec.getBackWood() + " back and sides,\n " + | ||
spec.getTopWood() + " top.\nYou can have it for only $" + | ||
guitar.getPrice() + "!\n ----"); | ||
} | ||
} else { | ||
System.out.println("Sorry, Erin, we have nothing for you."); | ||
} | ||
} | ||
|
||
private static void initializeInventory(Inventory inventory) { | ||
// 기타들을 재고 목록에 등 | ||
GuitarSpec spec = new GuitarSpec(Builder.FENDER, "Stratocaster", Type.ELECTRIC, 12, Wood.ALDER, Wood.ALDER); | ||
inventory.addGuitar("V95693", 1499.95, spec); | ||
inventory.addGuitar("V9512", 1549.95, spec); | ||
} | ||
|
||
} |
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,30 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
|
||
public class Guitar { | ||
|
||
private String serialNumber; | ||
private double price; | ||
private GuitarSpec spec; | ||
|
||
public Guitar(String serialNumber, double price, GuitarSpec spec) { | ||
this.serialNumber = serialNumber; | ||
this.price = price; | ||
this.spec = spec; | ||
} | ||
|
||
public String getSerialNumber() { | ||
return serialNumber; | ||
} | ||
|
||
public double getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(float newPrice) { | ||
this.price = newPrice; | ||
} | ||
|
||
public GuitarSpec getSpec() { | ||
return spec; | ||
} | ||
} |
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,59 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
|
||
public class GuitarSpec { | ||
|
||
private Builder builder; | ||
private String model; | ||
private Type type; | ||
private int numStrings; | ||
private Wood backWood; | ||
private Wood topWood; | ||
|
||
public GuitarSpec(Builder builder, String model, Type type, int numStrings, Wood backWood, | ||
Wood topWood) { | ||
this.builder = builder; | ||
this.model = model; | ||
this.type = type; | ||
this.numStrings = numStrings; | ||
this.backWood = backWood; | ||
this.topWood = topWood; | ||
} | ||
|
||
public Builder getBuilder() { | ||
return builder; | ||
} | ||
|
||
public String getModel() { | ||
return model; | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
public int getNumStrings() { | ||
return numStrings; | ||
} | ||
|
||
public Wood getBackWood() { | ||
return backWood; | ||
} | ||
|
||
public Wood getTopWood() { | ||
return topWood; | ||
} | ||
|
||
public boolean matches(GuitarSpec otherSpec) { | ||
if (builder != otherSpec.builder) | ||
return false; | ||
if ((model != null) && (!model.equals("")) && (!model.equals(otherSpec.model))) | ||
return false; | ||
if (type != otherSpec.type) | ||
return false; | ||
if (backWood != otherSpec.backWood) | ||
return false; | ||
if (topWood != otherSpec.topWood) | ||
return false; | ||
return true; | ||
} | ||
} |
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,43 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
|
||
public class Inventory { | ||
private List<Guitar> guitars; | ||
|
||
public Inventory() { | ||
guitars = new LinkedList<Guitar>(); | ||
} | ||
|
||
public void addGuitar(String serialNumber, double price, GuitarSpec spec) { | ||
Guitar guitar = new Guitar(serialNumber, price, spec); | ||
guitars.add(guitar); | ||
} | ||
|
||
public Guitar getGuitar(String serialNumber) { | ||
for (Iterator<Guitar> i = guitars.iterator(); i.hasNext(); ) { | ||
Guitar guitar = (Guitar)i.next(); | ||
if (guitar.getSerialNumber().equals(serialNumber)) { | ||
return guitar; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public List<Guitar> search(GuitarSpec searchSpec) { | ||
List<Guitar> matchingGuitars = new LinkedList<Guitar>(); | ||
for (Iterator<Guitar> i = guitars.iterator(); i.hasNext(); ) { | ||
Guitar guitar = (Guitar)i.next(); | ||
if (guitar.getSpec().matches(searchSpec)) { | ||
matchingGuitars.add(guitar); | ||
} | ||
} | ||
return matchingGuitars; | ||
} | ||
} | ||
|
||
|
||
|
||
|
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 com.boutiquelab.ooad.ch1; | ||
|
||
public enum Type { | ||
|
||
ACOUSTIC, ELECTRIC; | ||
|
||
public String toString() { | ||
switch(this) { | ||
case ACOUSTIC: | ||
return "acoustic"; | ||
case ELECTRIC: | ||
return "electric"; | ||
default: | ||
return "none"; | ||
} | ||
} | ||
} |
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,30 @@ | ||
package com.boutiquelab.ooad.ch1; | ||
|
||
public enum Wood { | ||
|
||
INDIAN_ROSEWOOD, BRAZILIAN_ROSEWOOD, MAHOGANY, MAPLE, COCOBOLO, CEDAR, ADIRONDACK, ALDER, SITKA; | ||
public String toString() { | ||
switch(this) { | ||
case INDIAN_ROSEWOOD: | ||
return "Indian Rosewood"; | ||
case BRAZILIAN_ROSEWOOD: | ||
return "Brazilian Rosewood"; | ||
case MAHOGANY: | ||
return "Mahogany"; | ||
case MAPLE: | ||
return "Maple"; | ||
case COCOBOLO: | ||
return "Cocobolo"; | ||
case CEDAR: | ||
return "Cedar"; | ||
case ADIRONDACK: | ||
return "Adirondack"; | ||
case ALDER: | ||
return "Alder"; | ||
case SITKA: | ||
return "Sitka"; | ||
default: | ||
return "none"; | ||
} | ||
} | ||
} |
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,23 @@ | ||
package com.boutiquelab.ooad.ch2; | ||
|
||
public class DogDoor { | ||
private boolean open; | ||
|
||
public DogDoor() { | ||
this.open = false; | ||
} | ||
|
||
public void open() { | ||
System.out.println("The dog door opens."); | ||
open = true; | ||
} | ||
|
||
public void close() { | ||
System.out.println("The dog door closes."); | ||
open = false; | ||
} | ||
|
||
public boolean isOpen() { | ||
return open; | ||
} | ||
} |
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 com.boutiquelab.ooad.ch2; | ||
|
||
public class DogDoorSimulator { | ||
public static void main(String[] args) { | ||
DogDoor door = new DogDoor(); | ||
Remote remote = new Remote(door); | ||
System.out.println("Fido barks to go outside..."); | ||
remote.pressButton(); | ||
System.out.println("\nFido has gone outside..."); | ||
System.out.println("\nFido's all done..."); | ||
|
||
try { | ||
Thread.currentThread(); | ||
Thread.sleep(10000); | ||
} catch (InterruptedException e) {} | ||
|
||
System.out.println("...but he's stuck outside!"); | ||
System.out.println("\nFido starts barking..."); | ||
System.out.println("...so Gina grabs the remote control."); | ||
remote.pressButton(); | ||
System.out.println("\nFido's back inside..."); | ||
|
||
} | ||
} |
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,29 @@ | ||
package com.boutiquelab.ooad.ch2; | ||
|
||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
public class Remote { | ||
private DogDoor door; | ||
|
||
public Remote(DogDoor door) { | ||
this.door = door; | ||
} | ||
|
||
public void pressButton() { | ||
System.out.println("Pressing the remote control button..."); | ||
if (door.isOpen()) { | ||
door.close(); | ||
} else { | ||
door.open(); | ||
|
||
final Timer timer = new Timer(); | ||
timer.schedule(new TimerTask() { | ||
public void run() { | ||
door.close(); | ||
timer.cancel(); | ||
} | ||
}, 5000); | ||
} | ||
} | ||
} |
Oops, something went wrong.