-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNatasha.java
124 lines (107 loc) · 3.14 KB
/
Natasha.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Natasha - A concept turned notion
* of a personal project of a personal assistant program.
*
* Real purpose: Java practice and exploration, and one never knows.
*
* Natasha version number documentation... x.y.z.
* x = serious version number, y = beta version number, z = session update number
*
* Current Fucntions: Login, Admin, Sys Admin, Date, Time, set Password, set User
* Updates this version: load and set User data, Sys Admin protocols
*
*/
package natasha;
import java.util.Scanner;
/**
*
* @author garyanewsome
*/
public class Natasha {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in); // initialize Scanner
// check to see if last login was successful and run system admin login if not.
SysAdmin sysAd = new SysAdmin("./sysadmin.txt");
boolean goodToGo = sysAd.checkLast();
if(!goodToGo){
sysAd.Login();
}
// constant representing system name and version number
final String V = "Natasha v.0.1.3";
// create user variables, and load data from User class
String name;
String pronoun;
User user = new User("./user.txt");
user.loadUser();
name = user.getName();
pronoun = user.getPronoun();
println(V);
println(name);
// create new login instance and check user password
Login login = new Login();
boolean accepted = login.checkPassword();
if (accepted) {
print("\nWelcome " + pronoun + ", the current time is ");
Clock.getTime();
println(".");
} else {
println("Login FAILURE!");
Admin admin = new Admin();
accepted = admin.checkPassword();
if (accepted) {
Clock.getDate();
println("\nAdmin priveledges available soon.");
} else {
println("Goodbye.");
}
}
sysAd.writeLast(accepted);
while (accepted){
int selection = menu(accepted, keyboard, pronoun);
switch (selection) {
case 0:
println("Have a pleasant day " + pronoun);
System.exit(0);
break;
case 1:
println("Coming soon...");
break;
case 2:
Clock.getDate();
break;
case 3:
Admin admin = new Admin();
if (accepted) {
login.setPass();
}
break;
case 4:
pronoun = user.setUser();
println(pronoun + " please reboot the system for the user"
+ " changes to take effect.");
}
}
// footer
println("\n" + V);
} // end main
public static int menu(boolean accepted, Scanner keyboard, String pronoun) {
println("1: Zander program (coming soon)");
println("2: Current date and time.");
println("3: Set password");
println("4: Set user");
println("0: Exit");
println("");
print("You selection " + pronoun + ": ");
int selection = keyboard.nextInt();
return selection;
} // end menu
public static void print(String msg) {
System.out.print(msg);
} // end print
public static void println(String msg) {
System.out.println(msg);
} // end println
}