Skip to content

Commit

Permalink
updated with two versions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulnguyen committed Nov 12, 2022
1 parent f74590d commit 153b243
Show file tree
Hide file tree
Showing 55 changed files with 1,076 additions and 22 deletions.
2 changes: 2 additions & 0 deletions demos/gaspump/.gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sat Nov 12 12:12:58 PST 2022
gradle.version=4.9
Empty file.
6 changes: 6 additions & 0 deletions demos/gaspump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Gas Pump Solutions

### Version 1 - Basic Solution

### Version 2 - Added Car Wash

21 changes: 0 additions & 21 deletions demos/gaspump/debug.log

This file was deleted.

Binary file removed demos/gaspump/gaspump.asta
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sat Nov 12 12:12:58 PST 2022
gradle.version=4.9
Empty file.
File renamed without changes.
File renamed without changes.
Binary file added demos/gaspump/gaspump_v1/gaspump.asta
Binary file not shown.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
130 changes: 130 additions & 0 deletions demos/gaspump/gaspump_v1/src/main/java/Screen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

import java.util.* ;
import java.util.Random ;

public class Screen implements IScreen
{
// ad message
private String[] ads = {
"Join our Rewards Program.",
"Hungry? Visit our Snack Bar.",
"Save with a Car Wash.",
"Star Wars Movie Preview.",
"New on HBO Now.",
"New iPhone 13 at AT&T.",
"Macy's Summer Clearance.",
"Get Your Smog Check Now."
};
private String ad = "" ;

// get random ad
private String getAd() {
Random rand = new Random() ;
int index = rand.nextInt(ads.length) ;
return ads[index] ;
}

// states
private State S0 = new State0(this) ;
private State S1 = new State1(this) ;
private State S2 = new State2(this) ;
private State S3 = new State3(this) ;
private State S4 = new State4(this) ;
private State S5 = new State5(this) ;
private State S6 = new State6(this) ;
private State S7 = new State7(this) ;

private State current = S0 ;

public void setState( int new_state ) {
switch ( new_state ) {
case 0: current = S0 ; break ;
case 1: current = S1 ; break ;
case 2: current = S2 ; break ;
case 3: current = S3 ; break ;
case 4: current = S4 ; break ;
case 5: current = S5 ; break ;
case 6: current = S6 ; break ;
case 7: current = S7 ; break ;
}
}

// commands
private ICommand cmd_a = new ICommand() {
public void execute() {
current.doA() ;
}
} ;
private ICommand cmd_b = new ICommand() {
public void execute() {
current.doB() ;
}
} ;
private ICommand cmd_c = new ICommand() {
public void execute() {
current.doC() ;
}
} ;
private ICommand cmd_d = new ICommand() {
public void execute() {
current.doD() ;
}
} ;
private ICommand cmd_e = new ICommand() {
public void execute() {
current.doE() ;
}
} ;
private ICommand cmd_f = new ICommand() {
public void execute() {
current.doF() ;
}
} ;
private ICommand cmd_g = new ICommand() {
public void execute() {
current.doG() ;
}
} ;
private ICommand cmd_h = new ICommand() {
public void execute() {
current.doH() ;
}
} ;


// enter keypad digits
public void key(String cmd) {
current.key( cmd ) ;
}

// instruction message
public String message() {
return current.message1() + "\n" + current.message2() + "\n" ;
}

// ad message
public String advertisement() {
return getAd() ;
}

// key press labels
public String A() { return current.A() ; }
public String B() { return current.B() ; }
public String C() { return current.C() ; }
public String D() { return current.D() ; }
public String E() { return current.E() ; }
public String F() { return current.F() ; }
public String G() { return current.G() ; }
public String H() { return current.H() ; }

// key press actions
public void selectA() { cmd_a.execute() ; }
public void selectB() { cmd_b.execute() ; }
public void selectC() { cmd_c.execute() ; }
public void selectD() { cmd_d.execute() ; }
public void selectE() { cmd_e.execute() ; }
public void selectF() { cmd_f.execute() ; }
public void selectG() { cmd_g.execute() ; }
public void selectH() { cmd_h.execute() ; }

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sat Nov 12 12:12:58 PST 2022
gradle.version=4.9
Empty file.
25 changes: 25 additions & 0 deletions demos/gaspump/gaspump_v2/Makefile
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

65 changes: 65 additions & 0 deletions demos/gaspump/gaspump_v2/build.gradle
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'
}





Binary file added demos/gaspump/gaspump_v2/gaspump.asta
Binary file not shown.
Binary file added demos/gaspump/gaspump_v2/gaspump.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 153b243

Please sign in to comment.