-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.java
56 lines (54 loc) · 1.52 KB
/
cli.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.Scanner;
import java.util.Random;
import java.io.*;
public class cli
{
private static Conways con;
private static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("File input? [1/0]");
int i = input.nextInt();
if (i > 0)
{
System.out.print("Filename: ");
con = concommon.fromFile(input.next(),con.numRows(),con.numColumns(),"rulesets/conways.txt");
}
else
{
System.out.print("How many rows and columns? ");
int r = input.nextInt();
int c = input.nextInt();
con = new Conways(r,c,null);
con.populate();
System.out.print("Output layout to file? [1/0]");
i = input.nextInt();
if (i > 0)
{
System.out.print("Filename: ");
String filename = input.next();
concommon.toFile(con,filename);
}
}
System.out.print("Log to File? [1/0]");
int f = input.nextInt();
if (f > 0)
{
System.out.print("Filename: ");
String filename = input.next();
try
{
System.setOut(new PrintStream( new BufferedOutputStream( new FileOutputStream(filename) ) ));
}
catch(Exception e)
{
System.out.println(e.getMessage());
System.out.println("Continuing with standard output");
}
}
while(true)
{
System.out.println(con);
con.generation();
}
}
}