-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
245fe7a
commit de80063
Showing
351 changed files
with
1,267 additions
and
100 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes
File renamed without changes
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,37 @@ | ||
|
||
public class Client { | ||
|
||
private String helloMessage = "Hello!" ; | ||
private Menu appMenu = new Menu() ; | ||
|
||
public Menu getMenu() { | ||
return appMenu ; | ||
} | ||
|
||
public void runSetup() { | ||
String helloMessage = "Ciao!" ; | ||
MenuItem hello = new MenuItem() ; | ||
Command sayHello = new ConcreteCommand(); | ||
sayHello.setReceiver( | ||
new Receiver() { | ||
public void doAction() { | ||
System.out.println( helloMessage ); | ||
} | ||
} | ||
); | ||
hello.setCommand( sayHello ); | ||
appMenu.addMenuItem(hello, "hello"); | ||
} | ||
|
||
public static void main( String [] args ) | ||
{ | ||
String helloMessage = "Bonjour!" ; | ||
Client c = new Client() ; | ||
c.runSetup() ; | ||
Menu m = c.getMenu() ; | ||
m.selectMenuItem("hello") ; | ||
} | ||
|
||
|
||
} | ||
|
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,7 @@ | ||
|
||
public interface Command { | ||
|
||
public abstract void execute(); | ||
public abstract void setReceiver(Receiver target); | ||
} | ||
|
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,15 @@ | ||
|
||
public class ConcreteCommand implements Command { | ||
|
||
private Receiver theReceiver ; | ||
|
||
public void execute() { | ||
theReceiver.doAction(); | ||
} | ||
|
||
public void setReceiver(Receiver target) { | ||
theReceiver = target ; | ||
} | ||
|
||
} | ||
|
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,7 @@ | ||
|
||
public interface Invoker { | ||
|
||
public abstract void setCommand(Command cmd); | ||
public abstract void invoke(); | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
import java.util.HashMap; | ||
|
||
public class Menu { | ||
|
||
private HashMap<String, MenuItem> menuItems = new HashMap<String, MenuItem>() ; | ||
|
||
public void addMenuItem( MenuItem item, String key ) { | ||
menuItems.put( key, item ) ; | ||
} | ||
|
||
public void selectMenuItem( String key ) { | ||
MenuItem item = menuItems.get(key) ; | ||
if ( item != null ) | ||
item.invoke(); | ||
else | ||
System.out.println( "Menu Item Not Found: " + key ); | ||
} | ||
|
||
} | ||
|
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,15 @@ | ||
|
||
public class MenuItem implements Invoker { | ||
|
||
private Command theCommand ; | ||
|
||
public void setCommand(Command cmd) { | ||
theCommand = cmd ; | ||
} | ||
|
||
public void invoke() { | ||
theCommand.execute(); | ||
} | ||
|
||
} | ||
|
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,7 @@ | ||
|
||
public interface Receiver { | ||
|
||
public void doAction() ; | ||
|
||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
all: clean | ||
|
||
clean: | ||
find . -name "*.class" -exec rm -rf {} \; | ||
rm -rf build/* | ||
rm -f *.log | ||
|
||
init: | ||
gradle init | ||
mkdir -p libs | ||
mkdir -p src/main/java | ||
mkdir -p src/test/java | ||
|
||
compile: | ||
gradle build -x test --warning-mode all | ||
|
||
test: | ||
gradle test | ||
|
||
jar: compile | ||
gradle shadowJar | ||
|
||
run: jar | ||
java -cp build/libs/gaspump-all.jar Main 2>debug.log | ||
|
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,65 @@ | ||
/* | ||
* This build file was auto generated by running the Gradle 'init' task | ||
* by 'pnguyen' at '7/30/18 6:20 PM' with Gradle 3.2.1 | ||
* | ||
* This generated file contains a commented-out sample Java project to get you started. | ||
* For more details take a look at the Java Quickstart chapter in the Gradle | ||
* user guide available at https://docs.gradle.org/3.2.1/userguide/tutorial_java_projects.html | ||
*/ | ||
|
||
/* | ||
// Apply the java plugin to add support for Java | ||
apply plugin: 'java' | ||
// In this section you declare where to find the dependencies of your project | ||
repositories { | ||
// Use 'jcenter' for resolving your dependencies. | ||
// You can declare any Maven/Ivy/file repository here. | ||
jcenter() | ||
} | ||
// In this section you declare the dependencies for your production and test code | ||
dependencies { | ||
// The production code uses the SLF4J logging API at compile time | ||
compile 'org.slf4j:slf4j-api:1.7.21' | ||
// Declare the dependency for your favourite test framework you want to use in your tests. | ||
// TestNG is also supported by the Gradle Test task. Just change the | ||
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add | ||
// 'test.useTestNG()' to your build script. | ||
testCompile 'junit:junit:4.12' | ||
} | ||
*/ | ||
|
||
|
||
buildscript { | ||
dependencies { | ||
classpath fileTree(dir: 'libs', include: '*.jar') | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java' | ||
id 'com.github.johnrengelman.shadow' version '2.0.4' | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
runtime fileTree(dir: 'libs', include: '*.jar') | ||
compile fileTree(dir: 'libs', include: '*.jar') | ||
compile group: 'junit', name: 'junit', version: '4.+' | ||
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21' | ||
testCompile group: 'junit', name: 'junit', version: '4.+' | ||
} | ||
|
||
shadowJar { | ||
baseName = 'gaspump' | ||
} | ||
|
||
|
||
|
||
|
||
|
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,21 @@ | ||
# lines: 1 | ||
line # 01 | ||
line len: 23 | ||
pad size: 9 | ||
new line: Do you want a Car Wash? | ||
new message: Do you want a Car Wash? | ||
|
||
# lines: 1 | ||
line # 01 | ||
line len: 23 | ||
pad size: 9 | ||
new line: Select Car Wash Package | ||
new message: Select Car Wash Package | ||
|
||
# lines: 1 | ||
line # 01 | ||
line len: 16 | ||
pad size: 12 | ||
new line: Credit or Debit? | ||
new message: Credit or Debit? | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.