-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF1Controller.java
More file actions
45 lines (38 loc) · 1.11 KB
/
Copy pathF1Controller.java
File metadata and controls
45 lines (38 loc) · 1.11 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
package com.f1drivers.projects;
import java.util.Scanner;
public class F1Controller {
static F1Repository repo=new F1Repository();
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
boolean condition=true;
while(condition) {
System.out.println("1.save the data 2.retrieve the data 3.exit");
int ch=sc.nextInt();
sc.nextLine();
switch(ch) {
case 1: save(sc);
break;
case 2: getAll(sc);
break;
case 3: System.out.println("exit");
break;
default:System.out.println("invalid option");
}
}
}
private static void save(Scanner sc) {
System.out.println("enter the Driver Name :");
String DriverName=sc.nextLine();
System.out.println("enter the Car Name :");
String CarName=sc.nextLine();
System.out.println("enter the trophies :");
int Trophies=sc.nextInt();
F1Model pm=new F1Model(DriverName, CarName, Trophies);
repo.save(pm);
System.out.println("data is saved");
}
private static void getAll(Scanner sc) {
repo.getAll();
System.out.println("retrievd all the data");
}
}