Skip to content

Commit f87d21c

Browse files
committed
Remove getCredits() & getGrade() from Class since it's basically a struct anyway
1 parent f3a222a commit f87d21c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

Class.java

-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@ public Class(int id, TextField title, ComboBox<String> grade, TextField credits,
1616
this.qualityPointsLabel=qualityPointsLabel;
1717
this.removeButton=removeButton;
1818
}
19-
20-
public String getGrade(){
21-
return grade.getValue();
22-
}
23-
24-
public String getCredits(){
25-
return credits.getText();
26-
}
2719
}

GpaModel.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public static boolean isEmptyString(String input){
5353

5454

5555
public boolean isClassValid(Class classObj){
56-
if(isEmptyString(classObj.getCredits())){
56+
if(isEmptyString(classObj.credits.getText())){
5757
return false;
5858
}
5959
return true;
6060
}
6161

6262
public void setQualityPoints(Class classObj){
63-
double qualityPoints = Integer.parseInt(classObj.getCredits()) * letterGradeToNumber.get(classObj.getGrade());
63+
double qualityPoints = Integer.parseInt(classObj.credits.getText()) * letterGradeToNumber.get(classObj.grade.getValue());
6464
classObj.qualityPointsLabel.setText(numberFormatter.format(GpaController.round(qualityPoints, 2)));
6565
}
6666

@@ -70,8 +70,8 @@ public void calcGpaOverall(ArrayList<Class> classes, TextField currentGPA, TextF
7070
for(Class c : classes){
7171
//Ignore invalid classes from the calculation
7272
if(isClassValid(c)){
73-
totalQualityPoints += Double.parseDouble(c.getCredits()) * letterGradeToNumber.get(c.getGrade());
74-
totalCredits += Integer.parseInt(c.getCredits());
73+
totalQualityPoints += Double.parseDouble(c.credits.getText()) * letterGradeToNumber.get(c.grade.getValue());
74+
totalCredits += Integer.parseInt(c.credits.getText());
7575
}
7676
}
7777
if(!isEmptyString(currentGPA.getText()) && !isEmptyString(currentCredits.getText()) && getGPAErrorIfInvalid(currentGPA.getText()).equals("")){

0 commit comments

Comments
 (0)