Skip to content

Commit 8966a18

Browse files
author
Pablo Fernandez
authored
Merge pull request #10 from WhitmanSWDesignSpring2017/project1-grading
Project1 grading
2 parents 69875ba + a23438d commit 8966a18

File tree

2 files changed

+74
-5
lines changed

2 files changed

+74
-5
lines changed

rubric.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
GRADE: 31/32
2+
------------
3+
4+
Functional requirements - 16 points
5+
===================================
6+
* 1/1 The window should have a Play Scale button.
7+
* 1/1 The window should have a Stop Playing button.
8+
* 3/3 When the user clicks the Play scale button, a dialog appears asking the user for a note number in the range 0 to 115.
9+
* 1/1 Then an 8-note scale is played starting at the given note.
10+
* 0/1 The scale should be the usual Do Re Mi Fa Sol La Ti Do notes going up in pitch. *See https://en.wikipedia.org/wiki/Solfège#Major *
11+
* 1/1 After playing the scale going up, it should then play the same scale again but going down from the highest note.
12+
* 1/1 The user might click the Play scale button when a scale is already being played. If the user clicks OK, then the scale being played should immediately stop and the new scale should be played instead. If the user clicks Cancel, then the scale currently playing should continue playing.
13+
* 1/1 When the user clicks the Stop playing button, the scale should stop playing immediately.
14+
* 1/1 The Play button and the Stop button should be visually distinct.
15+
* 1/1 The two buttons should be centered in the window next to each other but not touching each other.
16+
* 1/1 If the user shrinks or expands the window (for example, by dragging an edge or corner), the two buttons should remain centered in the window.
17+
* 1/1 The window should have a File menu with one menu item Exit.
18+
* 1/1 If the user selects this menu item, then the window disappears and the application quits.
19+
* 1/1 When the user clicks the close box (in the upper right or left corner of the window), the application quits just like when the user chooses the Exit menu item.
20+
21+
Implementation requirements - 8 points
22+
======================================
23+
* 2/2 Clone the given GitHub repository and push your code to it.
24+
* 2/2 Use JavaFX.
25+
* 1/1 Use the given MidiPlayer class.
26+
* 1/1 Put all your code in the provided ScalePlayer class.
27+
* 2/2 Document all methods using JavaDoc.
28+
29+
Elementary style - 4 points
30+
==========================
31+
* 1/1 Some attempt at descriptive method, parameter, and variable names.
32+
* 1/1 Consistent indentation.
33+
* 1/1 Appropriate use of basic language constructs; reasonably concise code.
34+
* 1/1 Code divided into methods.
35+
36+
Next time I will look for "self-explanatory code" and appropriate use of
37+
access modifiers.
38+
39+
Stretch goal - Extra Credit
40+
===========================
41+
* 0/0
42+
43+
Reflection - 4 points
44+
=====================
45+
* 1/1 Design overview
46+
* 2/2 What's elegant or not?
47+
* 1/1 How did your team collaborate?

src/scaleplayer/ScalePlayer.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,39 @@
2626
*/
2727
public class ScalePlayer extends Application {
2828

29+
//TODO: Why does this field exist?
2930
private static int startingNote;
31+
//TODO: Could this field be static, final?
3032
private MidiPlayer sequence = new MidiPlayer(2, 60);
3133

3234
/**
3335
* Start: Handles the menu bar, buttons, exits, and events.
34-
* @param primaryStage
36+
* @param primaryStage //TODO: What is it for?
3537
*/
3638
@Override
3739
public void start(Stage primaryStage) {
3840

3941
//create menu bar
4042
MenuBar menuBar = new MenuBar();
43+
//TODO: Is the next line necessary?
4144
menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
4245
Menu file = new Menu("File");
4346
menuBar.getMenus().add(file);
4447
MenuItem exitMenuItem = new MenuItem("Exit");
4548
file.getItems().add(exitMenuItem);
4649
exitMenuItem.setOnAction(actionEvent -> System.exit(0));
4750
primaryStage.setOnCloseRequest(e -> System.exit(0));
51+
//TODO: Confusing that the above line is here,
52+
//as it's not part of creating the menu bar
4853

4954
//play button
5055
Button playBtn = new Button();
5156
playBtn.setText("Play Scale");
57+
//NOTE: The below is ugly, but you'll fix it with CSS
5258
playBtn.setStyle("-fx-base: #b6e7c9;");
59+
//TODO: Is an anonymous inner class necessary?
5360
playBtn.setOnAction(new EventHandler<ActionEvent>() {
54-
61+
//TODO: This is way too much code to nest inside another method.
5562
/**
5663
* Handles the start and gets a note from the user, and starts the MidiPlayer using sequence.
5764
* @param event
@@ -61,10 +68,12 @@ public void handle(ActionEvent event) {
6168
TextInputDialog dialog = new TextInputDialog();
6269
dialog.setTitle("Starting Note");
6370
dialog.setHeaderText("Please enter a note (0-115)");
71+
//TODO: Set a default text input value
6472

6573
//get result, parse it into an int in a roundabout way, then play scale once its had
6674
Optional<String> result = dialog.showAndWait();
6775
if (result.isPresent()){
76+
//TODO: Why not just set startingNote to Integer.parseInt(result)?
6877
String stringResult = result.toString();
6978
stringResult = stringResult.substring(9, stringResult.length()-1);
7079
startingNote = Integer.parseInt(stringResult);
@@ -76,9 +85,11 @@ public void handle(ActionEvent event) {
7685
});
7786

7887
//stop button
88+
//TODO: See comments above
7989
Button stopBtn = new Button();
8090
stopBtn.setText("Stop Playing");
8191
stopBtn.setStyle("-fx-base: #eda6a6;");
92+
//TODO: Is an anonymous inner class necessary?
8293
stopBtn.setOnAction(new EventHandler<ActionEvent>() {
8394

8495
/**
@@ -100,8 +111,9 @@ public void handle(ActionEvent event) {
100111
hbox.setAlignment(Pos.CENTER);
101112

102113
//Overhead for showing screen
114+
//NOTE: Good choice
103115
BorderPane root = new BorderPane();
104-
116+
105117
root.setTop(menuBar);
106118
root.setCenter(hbox);
107119

@@ -110,14 +122,18 @@ public void handle(ActionEvent event) {
110122
primaryStage.setTitle("Scale Player");
111123
primaryStage.setScene(scene);
112124
primaryStage.show();
125+
126+
//NOTE: This method is much too long.
113127
}
114128

115129

116130
/**
117131
* Stops the current MidiPlayer sequence
118-
* @param sequence
132+
* @param sequence //TODO: What is it?
119133
*/
134+
//TODO: Why is this public?
120135
public void stopScale(MidiPlayer sequence) {
136+
//TODO: Why do you need to define a one line method?
121137
sequence.stop();
122138
}
123139

@@ -126,6 +142,7 @@ public void stopScale(MidiPlayer sequence) {
126142
* @param sequence
127143
*/
128144
public void clearScale(MidiPlayer sequence) {
145+
//TODO: See above
129146
sequence.clear();
130147
}
131148

@@ -135,7 +152,12 @@ public void clearScale(MidiPlayer sequence) {
135152
* @param sequence
136153
* @param startingNote
137154
*/
155+
//TODO: Why public?
138156
public void playScale(MidiPlayer sequence, int startingNote) {
157+
//TODO: Fix this so it's a Do-Re-Mi scale
158+
//https://en.wikipedia.org/wiki/Solfège#Major
159+
//TODO: Replace magic numbers with constants
160+
//TODO: Fix indentation
139161
for(int i=1; i<9; i++)
140162
{
141163
sequence.addNote(startingNote, 100, i, 1,
@@ -161,4 +183,4 @@ public static void main(String[] args) {
161183
launch(args);
162184
}
163185

164-
}
186+
}

0 commit comments

Comments
 (0)