-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrontendPlaceholder.java
More file actions
119 lines (98 loc) · 3.07 KB
/
Copy pathFrontendPlaceholder.java
File metadata and controls
119 lines (98 loc) · 3.07 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
118
119
import java.util.Scanner;
/**
* FrontendPlaceholder - CS400 Project 1: iSongify
*
* This class doesn't really work. The methods are hardcoded to output values
* as placeholders throughout development. It demonstrates the architecture
* of the Frontend class that will be implemented in a later week.
*/
public class FrontendPlaceholder implements FrontendInterface {
private String min = "min";
private String max = "max";
private String speed = "none";
public FrontendPlaceholder(Scanner in, BackendInterface backend) {}
/**
* Repeated gives the user an opportunity to issue new commands until
* they select Q to quit.
*/
public void runCommandLoop() {
displayMainMenu();
System.out.println("R"); // user entered command
readFile();
displayMainMenu();
System.out.println("G"); // user entered command
getValues();
displayMainMenu();
System.out.println("F"); // user entered command
setFilter();
displayMainMenu();
System.out.println("D"); // user entered command
topFive();
displayMainMenu();
System.out.println("Q"); // user entered command
}
/**
* Displays the menu of command options to the user.
*/
public void displayMainMenu() {
String menu = """
~~~ Command Menu ~~~
[R]ead Data
[G]et Songs by Energy [min - max]
[F]ilter Fast Songs (by Min Speed: none)
[D]isplay Five Most Danceable
[Q]uit
Choose command:""";
menu=menu.replace("min",min).replace("max",max).replace("none",speed);
System.out.print(menu + " ");
}
/**
* Provides text-based user interface and error handling for the
* [R]ead Data command.
*/
public void readFile() {
System.out.print("Enter path to csv file to load: ");
System.out.println("mySongData.csv"); // user entered command
System.out.println("Done reading file.");
}
/**
* Provides text-based user interface and error handling for the
* [G]et Songs by Energy command.
*/
public void getValues() {
System.out.print("Enter range of values (MIN - MAX): ");
System.out.println("80 - 90"); // user entered command
min="80";
max="90";
System.out.println("""
5 songs found between 80 - 90:
Baby
Dynamite
Secrets
Empire State of Mind (Part II) Broken Down
Only Girl (In The World)""");
}
/**
* Provides text-based user interface and error handling for the
* [F]ilter Fast Songs (by Min Speed) command.
*/
public void setFilter() {
System.out.print("Enter minimum speed: ");
System.out.println(85);
speed="85";
System.out.println("""
2 songs found between 80 - 90 at 85 BMP or faster:
Baby
Only Girl (In The World)""");
}
/**
* Provides text-based user interface and error handling for the
* [D]isplay Five Most Danceable command.
*/
public void topFive() {
System.out.println("""
Top Five Most Danceable found between 80 - 90 at 85 BMP or faster:
-5: Baby
-4: Only Girl (In The World)""");
}
}