-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInputDetails.java
More file actions
117 lines (105 loc) · 3.06 KB
/
InputDetails.java
File metadata and controls
117 lines (105 loc) · 3.06 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
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
import java.util.*;
public class InputDetails extends Exception
{
static int adult, child, totalPpl, travelMode, days, age[], count1=0, count2=0, count3=0, count4=0, count5=0, count6=0;
static long ph;
static String dest, email, address, dupT_Ppl, dupT_Mode, dup_Days, dup_Dest, fromDate, toDate;
static Scanner sc=new Scanner(System.in);
static boolean check1, check2, check3, check4;
public static void InputGTInfo()
{
//count1=0; count2=0;
if(count1==0){
System.out.println("\n->Enter Total Number Of People");
dupT_Ppl=sc.nextLine();
check1=isNumeric(dupT_Ppl);
if(check1){totalPpl=Integer.parseInt(dupT_Ppl); count1=1;}
}
if(count2==0){
System.out.println("\n1. Railways\n2. Airways\n->Enter mode of Travel");
dupT_Mode=sc.nextLine();
check2=isNumeric(dupT_Mode);
if(check2){
travelMode=Integer.parseInt(dupT_Mode);
if(travelMode!=1 && travelMode!=2){
System.out.println("--Enter Appropriate Option between 1 and 2 ONLY--");
}
else{count2=1;}
}
}
if(!check1 || !check2){
InputGTInfo();
}
else{if(count2==0){InputGTInfo();}}
}
public static void InputCTInfo()
{
//count3=0; count4=0; count5=0; count6=0;
if(count3==0){
System.out.println("->Enter Destination");
dup_Dest=sc.nextLine();
check1=isAlpha(dup_Dest);
if(check1){dest=dup_Dest; count3=1;}
}
if(count4==0){
System.out.println("\n->Enter Number Of Days");
dup_Days=sc.nextLine();
check2=isNumeric(dup_Days);
if(check2){days=Integer.parseInt(dup_Days); count4=1;}
}
if(count5==0){
System.out.println("\n->Enter Total Number Of People");
dupT_Ppl=sc.nextLine();
check3=isNumeric(dupT_Ppl);
if(check3){totalPpl=Integer.parseInt(dupT_Ppl); count5=1;}
}
if(count6==0){
System.out.println("\n1. Railways\n2. Airways\n->Enter mode of Travel");
dupT_Mode=sc.nextLine();
check4=isNumeric(dupT_Mode);
if(check4){
travelMode=Integer.parseInt(dupT_Mode);
if(travelMode!=1 && travelMode!=2){
System.out.println("--Enter Appropriate Option between 1 and 2 ONLY--");
}
else{count6=1;}
}
}
System.out.println("\n->Enter the Tour Dates:");
System.out.println("From-\t");
fromDate=sc.nextLine();
System.out.println("To-\t");
toDate=sc.nextLine();
if(!check1 || !check2 || !check3 || !check4){
InputCTInfo();
}
else{if(count6==0){InputCTInfo();}}
}
public static void InputPersonalInfo()
{
DetailsForm obj=new DetailsForm();
}
public static boolean isNumeric(String s){
try{
int n=Integer.parseInt(s);
}
catch(NumberFormatException nfe){
System.out.println("--You have entered a NON-NUMERIC Option--\n--Please Enter 'NUMERIC' & Appropriate Option--");
return false;
}
return true;
}
public static boolean isAlpha(String s){
try{
if(s != null && s.matches("^[a-zA-Z]*$")){return true;}
else{
InputDetails e=new InputDetails();
throw e;
}
}
catch(InputDetails e){
System.out.println("--You have entered a NON-ALPHABETIC Destination Name\nPlease Enter Appropriate Destination Name--");
return false;
}
}
}