-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraftOrder.java
95 lines (81 loc) · 3.03 KB
/
draftOrder.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
import java.util.Scanner;
public class draftOrder {
private static void oneUserStandardDraft() {
Scanner scan = new Scanner(System.in);
int rounds = inputValidation("How many rounds is your draft?");
int participants = inputValidation("How many participants are in your draft?");
int originalPick = inputValidation("What is the number of your first pick?");
scan.close();
int userPick;
int totalPicks = 0;
for (int i = 1; i <= rounds; i++) {
userPick = totalPicks + originalPick;
for (int j = 1; j <= participants; j++) {
totalPicks++;
if (totalPicks == userPick) {
System.out.println("Round " + i + ": \tOverall Pick: " + totalPicks);
}
}
}
}
private static void oneUserSnakeDraft() {
Scanner scan = new Scanner(System.in);
int rounds = inputValidation("How many rounds is your draft?");
int participants = inputValidation("How many participants are in your draft?");
int originalPick = inputValidation("What is the number of your first pick?");
scan.close();
int userPick;
int totalPicks = 0;
for (int i = 1; i <= rounds; i++) {
// Odd Round Number
if (i % 2 != 0) {
userPick = totalPicks + originalPick;
}
// Even Round Number
else {
userPick = totalPicks + participants - originalPick + 1;
}
for (int j = 1; j <= participants; j++) {
totalPicks++;
if (totalPicks == userPick) {
System.out.println("Round " + i + ": \tOverall Pick: " + totalPicks);
}
}
}
}
public static int inputValidation(String prompt) {
int value = 0;
Scanner scan = new Scanner(System.in);
boolean flag = false;
System.out.println(prompt);
// Making sure the input is an integer.
while (!(flag)) {
if (scan.hasNextInt()) {
value = scan.nextInt();
flag = true;
} else {
scan.next();
System.out.println("Input value must be a non-decimal number.");
}
}
return value;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("This program tells you all your draft picks in a draft");
System.out.println("What kind of draft is it? Type either Standard or Snake.");
String draftType = scan.nextLine();
switch (draftType) {
case "Standard":
oneUserStandardDraft();
break;
case "Snake":
oneUserSnakeDraft();
break;
default:
System.out.println("That was not one of the options. Please restart the program to try again.");
break;
}
scan.close();
}
}