diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 06:03:56 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 06:11:41 +0200 |
commit | a5c3599d7bc7a9ef5583ad2d50a55975f030fbea (patch) | |
tree | db4ed74e48997d4b4450148116a9c990978a1641 /src/com.example.portfolio2 | |
parent | 03d2d06e8f5bfadd79912efb94e8931e54296735 (diff) |
declare variables final when possible
Diffstat (limited to 'src/com.example.portfolio2')
5 files changed, 19 insertions, 19 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/Controller.java b/src/com.example.portfolio2/com/example/portfolio2/Controller.java index 2457e25..a948809 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Controller.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Controller.java @@ -29,7 +29,7 @@ class Controller{ /// /// @param store Storage model /// @param view Application view - Controller(Database store, Window view){ + Controller(final Database store, final Window view){ this.store = store; this.view = view; } @@ -38,7 +38,7 @@ class Controller{ /// @param combo involved activity box /// @param select selected item /// @param area whole text area - void onComboSelected(ComboBox<String> combo, ComboBox<String> select, TextArea area) { + void onComboSelected(final ComboBox<String> combo, final ComboBox<String> select, final TextArea area) { // clear the activity selection box select.getItems().clear(); @@ -55,7 +55,7 @@ class Controller{ /// @param combo involved activity box /// @param select selected item /// @param area whole text area - void onActivitySelected(ComboBox<String> combo, ComboBox<String> select, TextArea area) { + void onActivitySelected(final ComboBox<String> combo, final ComboBox<String> select, final TextArea area) { // pass the value chosen in the box addActivity(select.getValue(), area); @@ -71,7 +71,7 @@ class Controller{ /// @param subject1 involved 1st column subject module box /// @param subject2 involved 2nd column subject module box /// @param subjectModules list of selected subject modules - void onSubjectModuleSelected(ComboBox<String> subject1, ComboBox<String> subject2, List<String> subjectModules) { + 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) { @@ -86,7 +86,7 @@ class Controller{ /// add participation to database /// @param s activity identifier /// @param textArea whole text area - void addActivity(String s, TextArea textArea) { + void addActivity(final String s, final TextArea textArea) { store.addParticipation(store.getActivityIndeks(s)); } @@ -97,7 +97,7 @@ class Controller{ /// /// @param combo involved activity box /// @param textArea whole text area - void updateArea(ComboBox<String> combo, TextArea textArea) { + void updateArea(final ComboBox<String> combo, final TextArea textArea) { textArea.clear(); for(String s : store.getParticipation(combo.getValue())) { textArea.appendText(s + "\n"); @@ -107,11 +107,11 @@ class Controller{ /// update label with current ECTS of program type /// @param ectslabel text display area for ECTS points /// @param comboBox involved activity box - void updateEcts(Label ectslabel, ComboBox<String> comboBox) { + void updateEcts(final Label ectslabel, final ComboBox<String> comboBox) { ectslabel.setText("ECTS: "+store.getSumEcts(comboBox.getValue())); } - void fillElective(ComboBox<String> electiveBox) { + void fillElective(final ComboBox<String> electiveBox) { electiveBox.getItems().addAll(store.getAllActivities()); } } diff --git a/src/com.example.portfolio2/com/example/portfolio2/Database.java b/src/com.example.portfolio2/com/example/portfolio2/Database.java index 2712e3d..059bb3e 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Database.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Database.java @@ -28,7 +28,7 @@ class Database { /// /// @param name activity name /// @return index of activity as integer - int getActivityIndeks(String name) { + 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()); @@ -38,7 +38,7 @@ class Database { /// insert activity into participation /// /// @param activityIndex index of activity - void addParticipation(int activityIndex) { + void addParticipation(final int activityIndex) { db.cmd("insert into participation values(123, "+activityIndex+");"); } @@ -46,7 +46,7 @@ class Database { /// /// @param program programme name /// @return names of participating activities - ArrayList<String> getParticipation(String program) { + ArrayList<String> getParticipation(final String program) { return db.query("select name from participation p inner join activity a on p.indeks = a.indeks where program is '" + program + "';", "name"); } @@ -59,7 +59,7 @@ class Database { /// /// @param program programme name /// @return names of contained activities - ArrayList<String> selectProgram(String program) { + ArrayList<String> selectProgram(final String program) { return db.query("select name from activity where program is '" + program + "';", "name"); } @@ -67,7 +67,7 @@ class Database { /// /// @param program programme name /// @return ECTS points as String - String getSumEcts(String program){ + 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"; diff --git a/src/com.example.portfolio2/com/example/portfolio2/Main.java b/src/com.example.portfolio2/com/example/portfolio2/Main.java index da6524a..6d8922c 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Main.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Main.java @@ -15,7 +15,7 @@ public final class Main { /// JVM entry point /// /// @param args command-line arguments - public static void main(String[] args) { + public static void main(final String[] args) { Window.main(args); } } diff --git a/src/com.example.portfolio2/com/example/portfolio2/MyDB.java b/src/com.example.portfolio2/com/example/portfolio2/MyDB.java index 4eb07f4..9b02d39 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/MyDB.java +++ b/src/com.example.portfolio2/com/example/portfolio2/MyDB.java @@ -43,7 +43,7 @@ public class MyDB { /// foo /// @param sql foo - public void cmd(String sql) { + public void cmd(final String sql) { if (conn == null) open(); if (conn == null) { System.out.println("No connection"); @@ -71,7 +71,7 @@ public class MyDB { /// @param query foo /// @param fld foo /// @return foo - public ArrayList<String> query(String query, String fld) { + public ArrayList<String> query(final String query, final String fld) { ArrayList<String> res = new ArrayList<>(); if (conn == null) open(); if (conn == null) { diff --git a/src/com.example.portfolio2/com/example/portfolio2/Window.java b/src/com.example.portfolio2/com/example/portfolio2/Window.java index 3dccc42..cb856f9 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Window.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Window.java @@ -37,7 +37,7 @@ public final class Window extends Application { private Controller con = new Controller(store,this); @Override - public void start(Stage stage) throws IOException { + public void start(final Stage stage) throws IOException { // clear old insertions into participation table con.initialize(); @@ -111,7 +111,7 @@ public final class Window extends Application { /// JVM entry point /// /// @param args command-line arguments - public static void main(String[] args) { + public static void main(final String[] args) { launch(); } @@ -139,7 +139,7 @@ public final class Window extends Application { /// column of activities /// /// @param name identifier - ActivityColumn(String name) { + ActivityColumn(final String name) { this.name = name; nameLabel = new Label(name); categoryCombo = new ComboBox<>(); |