Repository navigation
Expand file tree
/
Copy pathTechnician
More file actions
69 lines (61 loc) · 2.33 KB
/
Copy pathTechnician
File metadata and controls
69 lines (61 loc) · 2.33 KB
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
import java.io.*;
import java.util.Scanner;
public class technician {
public static void showOptions(){
System.out.println("1 --> Enter maintenance work");
System.out.println("2 --> Exit");
}
public static void goBackTechnician() throws IOException {
Scanner sc = new Scanner(System.in);
System.out.println("\nChoose from the below options");
System.out.println("1 --> Remain as technician");
System.out.println("2 --> Go to main menu");
System.out.println("3 --> Exit");
int exit = sc.nextInt();
if (exit == 1){
enterToT();
}
else if (exit == 2){
Main.mainMenu();
}
else {
System.out.println("\nExiting the program, have a good day!");
}
}
public static void makeRecord() throws FileNotFoundException {
FileOutputStream fos = new FileOutputStream("maintenanceRecords.csv", true);
PrintWriter pw = new PrintWriter(fos);
Scanner sc = new Scanner(System.in);
System.out.println("Enter vehicle ID: ");
String ID = sc.nextLine();
System.out.println("Enter name of technician: ");
String name = sc.nextLine();
System.out.println("Enter relevant price of job: ");
int cost = sc.nextInt();
pw.println(ID+","+name+","+cost);
pw.close();
}
public static void enterToT() throws IOException {
System.out.println("----------------------------------------------------------------------------------------------------");
Scanner d = new Scanner(System.in);
System.out.println("Enter Username:");
String userName = d.nextLine();
System.out.println("Enter Password:");
int passWord = d.nextInt();
if ((userName.equals("technician123")) && (passWord == 5678)) {
System.out.println("----------------------------------------------------------------------------------------------------");
technician.showOptions();
System.out.println("Enter index of task to be done:");
int task = d.nextInt();
if (task == 1){
technician.makeRecord();
}
else{
technician.goBackTechnician();
}
}
else {
Main.goBackToMainMenu();
}
}
}