Placeholder project. Will be changed.

deliverable_2
asdfasdf 6 years ago
parent d8aa149a6b
commit d3f2297d27

@ -6,25 +6,28 @@ dependencies {
testCompile fileTree(include: ['*.jar'], dir:'lib')
testImplementation fileTree(include: ['*.jar'], dir:'lib')
testRuntime fileTree(include: ['*.jar'], dir:'lib')
checkstyle files('lib/checkstyle-8.20-all.jar')
checkstyle files('lib/checkstyle-8.20-all.jar')
}
checkstyle {
toolVersion '8.20'
configFile file('checkstyle.xml')
configFile file('checkstyle.xml')
}
sourceSets {
main {
java {
srcDir 'src/main'
}
}
test {
java {
srcDir 'src/test'
}
}
main {
java {
srcDir 'src/main'
}
resources {
srcDir "src/resources"
}
}
test {
java {
srcDir 'src/test'
}
}
}
test {
useJUnitPlatform()
@ -34,18 +37,30 @@ test {
}
task run(type: JavaExec) {
group = 'Run'
description = 'Run main'
group = 'Run'
description = 'Run main'
standardInput = System.in
classpath sourceSets.main.runtimeClasspath
main = "ui.Main"
//args "arg1", "arg2"
}
task debug(type: JavaExec) {
group = 'Run'
description = 'Debug main'
standardInput = System.in
classpath sourceSets.main.runtimeClasspath
main = "ui"
//args "arg1", "arg2"
classpath sourceSets.main.runtimeClasspath
main = "ui.Main"
debug = true
//args "arg1", "arg2"
}
task tags(type: Exec) {
description = 'Update tags file'
commandLine 'ctags', '-R', 'src'
description = 'Update tags file'
commandLine 'ctags', '-R', 'src'
}
checkstyleMain {

@ -0,0 +1,16 @@
import javax.swing.*;
public class Gui {
//public Gui() {
// JLabel label = new JLabel("Hello World");
// JFrame.setDefaultLookAndFeelDecorated(true);
// JFrame f = new JFrame("Hello World");
// f.setSize(300,150);
// f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// f.add(label);
// f.setVisible(true);
//}
}

@ -1,18 +1,5 @@
package ui;
import data.Options;
public class Iface {
public static void main(String[] args) {
System.out.println("Starting Main");
helloWorld();
helloWorld2();
System.out.println("Exiting...");
}
public static void helloWorld() {
System.out.println("Hello world");
}
public static void helloWorld2() {
System.out.println("Hello world2");
}
public abstract class Iface {
private Options ifaceOpts;
}

@ -0,0 +1,7 @@
import data.Options;
//import ui.Iface;
public class IfaceFactory {
//public Iface getIface(Options IfaceOptions){
//}
}

@ -0,0 +1,66 @@
package ui;
import java.util.*;
public class Main {
public static final String PROGRAM_NAME = "Num guess";
//public static final String USAGE_TEXT = "Usage";
private int win;
private int games;
//private Iface iface;
//private Options allOptions;
//Constructor, not the java main
public Main(String[] args) {
//options = new Options();
System.out.println("Welcome to " + PROGRAM_NAME + "!");
guess();
}
// java main
public static void main(String[] args) {
new Main(args);
}
public void guess() {
Random rand = new Random();
while (true) {
int range = rand.nextInt(1000);
int secret = rand.nextInt(range);
System.out.println("Can you guess my number? [0 - " + range + "]");
System.out.println("Enter -1 to end");
int user = getUserInt();
if (user < 0) {
break;
} else {
guessResult(user, secret);
}
}
}
public int getUserInt() {
Scanner scan = new Scanner(System.in);
int result = scan.nextInt();
scan.close();
return result;
}
public void guessResult(int user, int secret) {
if (user < secret || user > secret) {
this.games++;
System.out.println("Too bad. You guessed "
+ secret + " with " + user + ".");
} else {
this.games++;
this.win++;
System.out.println("Wonderful! You have correctly guessed: "
+ secret + " with " + user + "!");
}
}
public void end() {
System.out.println("You have won: " + this.win + " out of " + this.games
+ "!");
System.out.println("Thank you for playing this game! Bye!");
}
}

@ -0,0 +1,36 @@
import java.util.*;
//import ui.Iface;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Tui extends Iface {
private static final String SAVE_CURSOR = "\u001b[s";
private static final String RESTORE_CURSOR = "\u001b[s";
private static final String REQUEST_CURSOR = "\u001b[6n";
private int maxcol;
private int maxrow;
private BufferedReader stdin;
public Tui() {
// stdin = new BufferedReader(new InputStreamReader(System.in));
}
//public String getInput() {
//}
//public getCursor(){
// if (stdin.ready()) {
// System.out.print(REQUEST_CURSOR);
// stdin.skip(1);
// char c;
// while (char = (char)stdin.read() != ';') {
// row =
// }
// }
//}
//public void moveCursor(int col, int row) {
// System.out.print("\u001b["+col+";"+row+"H");
//}
}
Loading…
Cancel
Save