-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUberDriver.java
More file actions
55 lines (45 loc) · 1.61 KB
/
Copy pathUberDriver.java
File metadata and controls
55 lines (45 loc) · 1.61 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
import java.util.Scanner;
public class UberDriver
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
Uber uber = new Uber();
System.out.println("\n----------Welcome To Uber----------\n");
char choice2 = '\u0000';
do
{
System.out.println("PRESS 1 FOR : SUV");
System.out.println("PRESS 2 FOR : SEDAN");
System.out.println("PRESS 3 FOR : MINI");
System.out.println("\n ENTER YOUR CHOICE : ");
int choice1 = s.nextInt();
choice2='\u0000';
switch (choice1) {
case 1:{
System.out.print("ENTER DISTANCE : ");
uber.cab =new SUV(s.nextInt()); //UPCASTED SCENARIO
break;
}
case 2:{
System.out.print("ENTER DISTANCE : ");
uber.cab =new Sedan(s.nextInt());
break;
}
case 3:{
System.out.print("ENTER DISTANCE : ");
uber.cab =new Mini(s.nextInt());
break;
}
default:{
System.out.println("\n.......INVALID INPUT.......\n");
System.out.print("\tDO YOU WANT TO CONTINUE (Y/N) : ");
choice2 = s.next().charAt(0);
}
}
}while(choice2 == 'y' || choice2 == 'Y');
// DISPLAYING PROPERTIES OF CAB SELECTED
System.out.println(uber.cab);
Uber.displayDetails(uber.cab);
}
}