diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 07:19:10 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 07:19:10 +0200 |
commit | 705b7a5a32793f7ed8a24b8b35afe3f9d49348be (patch) | |
tree | 7cffeb0de03a4638b87f04e01e7193eacbeaeede /src/com.example.portfolio2 | |
parent | a5c3599d7bc7a9ef5583ad2d50a55975f030fbea (diff) |
tidy whitespace
Diffstat (limited to 'src/com.example.portfolio2')
4 files changed, 22 insertions, 17 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/Controller.java b/src/com.example.portfolio2/com/example/portfolio2/Controller.java index a948809..036236f 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Controller.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Controller.java @@ -12,7 +12,7 @@ import javafx.scene.control.TextArea; import java.util.List; /// Bachelorizer - Controller -class Controller{ +class Controller { /// Storage model private Database store; @@ -29,8 +29,9 @@ class Controller{ /// /// @param store Storage model /// @param view Application view - Controller(final Database store, final Window view){ - this.store = store; this.view = view; + Controller(final Database store, final Window view) { + this.store = store; + this.view = view; } /// callback when category box is selected @@ -74,7 +75,7 @@ class Controller{ void onSubjectModuleSelected(final ComboBox<String> subject1, final ComboBox<String> subject2, final List<String> subjectModules) { // Beautiful loop we've created to remove option chosen in one subject module box from the other - for (String sub : subjectModules) { + for (String sub: subjectModules) { if (sub.equals(subject1.getValue())) { subject2.getItems().remove(subject1.getValue()); } else if (!sub.equals(subject1.getValue()) && !subject2.getItems().contains(sub)) { @@ -99,7 +100,7 @@ class Controller{ /// @param textArea whole text area void updateArea(final ComboBox<String> combo, final TextArea textArea) { textArea.clear(); - for(String s : store.getParticipation(combo.getValue())) { + for (String s: store.getParticipation(combo.getValue())) { textArea.appendText(s + "\n"); } } @@ -108,7 +109,7 @@ class Controller{ /// @param ectslabel text display area for ECTS points /// @param comboBox involved activity box void updateEcts(final Label ectslabel, final ComboBox<String> comboBox) { - ectslabel.setText("ECTS: "+store.getSumEcts(comboBox.getValue())); + ectslabel.setText("ECTS: " + store.getSumEcts(comboBox.getValue())); } void fillElective(final ComboBox<String> electiveBox) { diff --git a/src/com.example.portfolio2/com/example/portfolio2/Database.java b/src/com.example.portfolio2/com/example/portfolio2/Database.java index 059bb3e..a4a9271 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Database.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Database.java @@ -17,7 +17,7 @@ class Database { /// default constructor // (declared explicitly only to silence javadoc) - Database() {} + Database() { } /// clear the participation database at program launch void initialize() { @@ -29,17 +29,18 @@ class Database { /// @param name activity name /// @return index of activity as integer int getActivityIndeks(final String name) { - if(name ==null) return -1; - ArrayList<String> result = db.query("select indeks from activity a where name is '"+name+"';", "indeks"); - return Integer.parseInt(result.getFirst()); + if (name == null) + return -1; + ArrayList<String> result = db.query("select indeks from activity a where name is '" + name + "';", "indeks"); + return Integer.parseInt(result.getFirst()); } /// insert activity into participation /// /// @param activityIndex index of activity void addParticipation(final int activityIndex) { - db.cmd("insert into participation values(123, "+activityIndex+");"); + db.cmd("insert into participation values(123, " + activityIndex + ");"); } /// list currently participating activities @@ -67,10 +68,13 @@ class Database { /// /// @param program programme name /// @return ECTS points as String - String getSumEcts(final String program){ - if(program==null)return "0"; - ArrayList<String> result = db.query("select sum(activity.ects) as total_ects,student.name from student left outer join participation on student.studid = participation.studid inner join activity on participation.indeks = activity.indeks where program is '"+program+"' group by student.studid ;", "total_ects"); - if (result.isEmpty()) return "0"; + String getSumEcts(final String program) { + if (program == null) + return "0"; + ArrayList<String> result = db.query("select sum(activity.ects) as total_ects,student.name from student left outer join participation on student.studid = participation.studid inner join activity on participation.indeks = activity.indeks where program is '" + program + "' group by student.studid ;", "total_ects"); + if (result.isEmpty()) + return "0"; + return result.getFirst(); } diff --git a/src/com.example.portfolio2/com/example/portfolio2/Main.java b/src/com.example.portfolio2/com/example/portfolio2/Main.java index 6d8922c..7b0b33c 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Main.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Main.java @@ -10,7 +10,7 @@ public final class Main { /// Default constructor // (declared explicitly only to silence javadoc) - public Main() {} + public Main() { } /// JVM entry point /// diff --git a/src/com.example.portfolio2/com/example/portfolio2/Window.java b/src/com.example.portfolio2/com/example/portfolio2/Window.java index cb856f9..2a92241 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Window.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Window.java @@ -24,7 +24,7 @@ public final class Window extends Application { /// Default constructor // (declared explicitly only to silence javadoc) - public Window() {} + public Window() { } /// Label styling public static final String LABEL_STYLE = |