aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-29 06:03:56 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-29 06:11:41 +0200
commita5c3599d7bc7a9ef5583ad2d50a55975f030fbea (patch)
treedb4ed74e48997d4b4450148116a9c990978a1641 /src
parent03d2d06e8f5bfadd79912efb94e8931e54296735 (diff)
declare variables final when possible
Diffstat (limited to 'src')
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Controller.java16
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Database.java10
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Main.java2
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/MyDB.java4
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Window.java6
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java4
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/AdjListGraph.java6
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/AdjMapGraph.java6
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/Edge.java2
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java6
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/GraphAlgorithms.java38
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java10
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/Vertex.java2
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Control.java6
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/GUI.java4
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java12
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Main.java2
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Person.java2
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java10
19 files changed, 74 insertions, 74 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<>();
diff --git a/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java b/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java
index eff245c..95c1030 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java
@@ -21,7 +21,7 @@ public abstract class AbstractGraph implements Graph{
/// foo
/// @param s foo
/// @return Vertex
- public Vertex vertex(String s){
+ public Vertex vertex(final String s){
if(vertexMap.containsKey(s))return vertexMap.get(s);
Vertex v=new Vertex(s);
vertexMap.put(s,v);
@@ -30,7 +30,7 @@ public abstract class AbstractGraph implements Graph{
}
/// foo
- public void insertEdge(String v, String u, int w){
+ public void insertEdge(final String v, final String u, final int w){
insertEdge(vertex(v),vertex(u),w);
}
diff --git a/src/com.example.portfolio3/com/example/portfolio3/AdjListGraph.java b/src/com.example.portfolio3/com/example/portfolio3/AdjListGraph.java
index babaaaa..765eeca 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/AdjListGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/AdjListGraph.java
@@ -18,7 +18,7 @@ public class AdjListGraph extends AbstractGraph {
private Map<Vertex,Set<Edge>> outEdge= new HashMap<>();
/// foo
- public void insertEdge(Vertex v1,Vertex v2,int w){
+ public void insertEdge(final Vertex v1, final Vertex v2, final int w){
Edge e=new Edge(v1,v2,w);
if(!outEdge.containsKey(e.from()))
outEdge.put(e.from(),new HashSet<Edge>());
@@ -33,14 +33,14 @@ public class AdjListGraph extends AbstractGraph {
}
/// foo
- public Collection<Edge> outEdge(Vertex v){
+ public Collection<Edge> outEdge(final Vertex v){
if(!outEdge.containsKey(v))
return new HashSet<Edge>();
return outEdge.get(v);
}
/// foo
- public Integer getWeight(Vertex v1,Vertex v2){
+ public Integer getWeight(final Vertex v1, final Vertex v2){
// linear in number of outedges from vertices
if(!outEdge.containsKey(v1))return null;
for(Edge e:outEdge.get(v1)){
diff --git a/src/com.example.portfolio3/com/example/portfolio3/AdjMapGraph.java b/src/com.example.portfolio3/com/example/portfolio3/AdjMapGraph.java
index f12df6f..353f934 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/AdjMapGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/AdjMapGraph.java
@@ -18,7 +18,7 @@ class AdjMapGraph extends AbstractGraph {
private Map<Vertex, Map<Vertex, Edge>> outEdge = new HashMap<>();
/// foo
- public void insertEdge(Vertex v1, Vertex v2, int w) {
+ public void insertEdge(final Vertex v1, final Vertex v2, final int w) {
Edge e = new Edge(v1,v2, w);
if (!outEdge.containsKey(e.from()))
outEdge.put(e.from(), new HashMap<Vertex, Edge>());
@@ -35,12 +35,12 @@ class AdjMapGraph extends AbstractGraph {
}
/// foo
- public Collection<Edge> outEdge(Vertex v) {
+ public Collection<Edge> outEdge(final Vertex v) {
return outEdge.get(v).values();
}
/// foo
- public Integer getWeight(Vertex v1, Vertex v2) {
+ public Integer getWeight(final Vertex v1, final Vertex v2) {
// constant time operation
if(!outEdge.containsKey(v1))return null;
if(!outEdge.get(v1).containsKey(v2))return null;
diff --git a/src/com.example.portfolio3/com/example/portfolio3/Edge.java b/src/com.example.portfolio3/com/example/portfolio3/Edge.java
index f5d54db..7cb8d5a 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/Edge.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/Edge.java
@@ -27,7 +27,7 @@ public class Edge{
/// @param from foo
/// @param to foo
/// @param w foo
- Edge(Vertex from,Vertex to,int w){this.from=from; this.to=to; weight=w;}
+ Edge(final Vertex from, final Vertex to, final int w){this.from=from; this.to=to; weight=w;}
/// foo
/// @return String
diff --git a/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java b/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java
index 22cfe87..979b118 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java
@@ -17,7 +17,7 @@ class EdgeGraph extends AbstractGraph {
Set<Edge> edges=new HashSet<>();
/// foo
- public void insertEdge(Vertex v1,Vertex v2,int w){
+ public void insertEdge(final Vertex v1, final Vertex v2, final int w){
edges.add(new Edge(v1,v2,w));
}
@@ -25,14 +25,14 @@ class EdgeGraph extends AbstractGraph {
public Collection<Edge> edges(){return edges;}
/// foo
- public Collection<Edge> outEdge(Vertex v){
+ public Collection<Edge> outEdge(final Vertex v){
ArrayList<Edge> outEdge=new ArrayList<>();
for(Edge e:edges)if(e.from()==v)outEdge.add(e);
return outEdge;
}
/// foo
- public Integer getWeight(Vertex v1,Vertex v2){
+ public Integer getWeight(final Vertex v1, final Vertex v2){
// linear in number of edges in the graph
for(Edge e:edges){
if(e.from()==v1 && e.to()==v2)return e.weight();
diff --git a/src/com.example.portfolio3/com/example/portfolio3/GraphAlgorithms.java b/src/com.example.portfolio3/com/example/portfolio3/GraphAlgorithms.java
index 9337ac1..d2a20f2 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/GraphAlgorithms.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/GraphAlgorithms.java
@@ -27,7 +27,7 @@ public class GraphAlgorithms {
/// does not require the edges to form a path
/// @param edges foo
/// @return int
- public static int pathLength(Collection<Edge> edges){
+ public static int pathLength(final Collection<Edge> edges){
return edges.stream().mapToInt(e-> e.weight()).sum();
}
@@ -36,7 +36,7 @@ public class GraphAlgorithms {
/// the to-vertex in one edge is the from-vertex of the next
/// @param edges foo
/// @return boolean
- public static boolean isPath(List<Edge> edges){
+ public static boolean isPath(final List<Edge> edges){
for(int i=1;i<edges.size();i++){
if(edges.get(i-1).to()!=edges.get(i).from())return false;
}
@@ -49,7 +49,7 @@ public class GraphAlgorithms {
/// @param g foo
/// @param path foo
/// @return Integer
- public static Integer pathLength(Graph g,List<Vertex> path){
+ public static Integer pathLength(final Graph g, final List<Vertex> path){
int length=0;
for(int i=1;i<path.size();i++){
Integer w=g.getWeight(path.get(i-1),path.get(i));
@@ -69,7 +69,7 @@ public class GraphAlgorithms {
/// @param e1 foo
/// @param e2 foo
/// @return int
- static int cmpEdgeWeight(Edge e1,Edge e2) {
+ static int cmpEdgeWeight(final Edge e1, final Edge e2) {
int w1=e1.weight(),w2=e2.weight();
if(w1!=w2)return w1-w2;
if(e1.from()!=e2.from())return e1.from().name().compareTo(e2.from().name());
@@ -82,7 +82,7 @@ public class GraphAlgorithms {
/// @param e1 foo
/// @param e2 foo
/// @return int
- static int cmpEdgeFrom(Edge e1,Edge e2) {
+ static int cmpEdgeFrom(final Edge e1, final Edge e2) {
if(e1.from()!=e2.from())return e1.from().name().compareTo(e2.from().name());
int w1=e1.weight(),w2=e2.weight();
if(w1!=w2)return w1-w2;
@@ -95,7 +95,7 @@ public class GraphAlgorithms {
/// @param e1 foo
/// @param e2 foo
/// @return int
- static int cmpEdgeTo(Edge e1,Edge e2) {
+ static int cmpEdgeTo(final Edge e1, final Edge e2) {
if(e1.to()!=e2.to())return e1.to().name().compareTo(e2.to().name());
if(e1.from()!=e2.from())return e1.from().name().compareTo(e2.from().name());
int w1=e1.weight(),w2=e2.weight();
@@ -105,7 +105,7 @@ public class GraphAlgorithms {
/// sort a collection of edges based on their weights
/// @param edges foo
/// @return List<Edge>
- static List<Edge> sortEdges(Collection<Edge> edges){
+ static List<Edge> sortEdges(final Collection<Edge> edges){
ArrayList<Edge> list=new ArrayList<>(edges);
Collections.sort(list,GraphAlgorithms::cmpEdgeWeight);
return list;
@@ -114,7 +114,7 @@ public class GraphAlgorithms {
/// sort a collection of edges based on from-vertex
/// @param edges foo
/// @return List<Edge>
- static List<Edge> sortEdgesFrom(Collection<Edge> edges){
+ static List<Edge> sortEdgesFrom(final Collection<Edge> edges){
ArrayList<Edge> list=new ArrayList<>(edges);
Collections.sort(list,GraphAlgorithms::cmpEdgeFrom);
return list;
@@ -123,7 +123,7 @@ public class GraphAlgorithms {
/// sort a collection of edges based on to-vertex
/// @param edges foo
/// @return List<Edge>
- static List<Edge> sortEdgesTo(Collection<Edge> edges){
+ static List<Edge> sortEdgesTo(final Collection<Edge> edges){
ArrayList<Edge> list=new ArrayList<>(edges);
Collections.sort(list,GraphAlgorithms::cmpEdgeTo);
return list;
@@ -132,7 +132,7 @@ public class GraphAlgorithms {
/// sort a collection of vertices based on their name
/// @param vertices foo
/// @return List<Vertex>
- public static List<Vertex> sortVertex(Collection<Vertex> vertices){
+ public static List<Vertex> sortVertex(final Collection<Vertex> vertices){
ArrayList<Vertex> list=new ArrayList<>(vertices);
Collections.sort(list,(Vertex v1,Vertex v2)-> v1.name().compareTo(v2.name()));
return list;
@@ -147,7 +147,7 @@ public class GraphAlgorithms {
/// @param g foo
/// @param v foo
/// @return Set<Vertex>
- public static Set<Vertex> visitBreadthFirst(Graph g,Vertex v){
+ public static Set<Vertex> visitBreadthFirst(final Graph g, final Vertex v){
HashSet<Vertex> thisLevel=new HashSet<>();
HashSet<Vertex> nextLevel=new HashSet<>();
HashSet<Vertex> visited=new HashSet<>();
@@ -176,7 +176,7 @@ public class GraphAlgorithms {
/// @param g foo
/// @param v foo
/// @return Set<Vertex>
- public static Set<Vertex> visitDepthFirst(Graph g,Vertex v){
+ public static Set<Vertex> visitDepthFirst(final Graph g, final Vertex v){
HashSet<Vertex> visit=new HashSet<>();
visitDepthFirst(g, v,visit);
return visit;
@@ -186,7 +186,7 @@ public class GraphAlgorithms {
/// @param g foo
/// @param v foo
/// @param visited foo
- private static void visitDepthFirst(Graph g,Vertex v,Set<Vertex> visited){
+ private static void visitDepthFirst(final Graph g, final Vertex v, final Set<Vertex> visited){
if(visited.contains(v))return;
//System.out.println("visited "+v);
visited.add(v);
@@ -198,7 +198,7 @@ public class GraphAlgorithms {
/// naive implementation without priorityqueue
/// @param g foo
/// @return Set<Edge>
- public static Set<Edge> minimumSpanningTree(Graph g){
+ public static Set<Edge> minimumSpanningTree(final Graph g){
Collection<Edge> edges=g.edges();
HashSet<Edge> mst=new HashSet<>();
HashSet<Vertex> frontier=new HashSet<>();
@@ -225,7 +225,7 @@ public class GraphAlgorithms {
/// @param g foo
/// @param start foo
/// @return Set<Edge>
- public static Set<Edge> dijkstra(Graph g, Vertex start){
+ public static Set<Edge> dijkstra(final Graph g, final Vertex start){
// create table for done, prev and weight from start
int maxint =Integer.MAX_VALUE;
HashSet<Vertex> done=new HashSet<>();
@@ -280,7 +280,7 @@ public class GraphAlgorithms {
/// stores file as bidirectional graph
/// @param g foo
/// @param file foo
- public static void readGraph(Graph g, String file) {
+ public static void readGraph(final Graph g, final String file) {
try{
BufferedReader in = new BufferedReader(new FileReader(file));
for(String line=in.readLine(); line!=null; line=in.readLine()) {
@@ -298,7 +298,7 @@ public class GraphAlgorithms {
/// foo
/// @param g foo
- public static void printGraph(Graph g) {
+ public static void printGraph(final Graph g) {
for(Vertex v: sortVertex(g.vertices())) {
System.out.println(v.toString());
for(Edge e:sortEdgesTo(g.outEdge(v)))
@@ -309,7 +309,7 @@ public class GraphAlgorithms {
/// store a list of lines as a file
/// @param list foo
/// @param f foo
- public static void storeStrings(List<String> list,String f){
+ public static void storeStrings(final List<String> list, final String f){
try{
PrintWriter out=new PrintWriter(new FileWriter(f));
for(String s:list){
@@ -324,7 +324,7 @@ public class GraphAlgorithms {
/// read a file a returns a list of lines
/// @param f foo
/// @return ArrayList
- public static ArrayList<String> loadStrings(String f){
+ public static ArrayList<String> loadStrings(final String f){
ArrayList<String> list=new ArrayList<>();
try{
BufferedReader in=new BufferedReader(new FileReader(f));
diff --git a/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java b/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
index aac4726..985fcbb 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
@@ -25,7 +25,7 @@ public class MatrixGraph extends AbstractGraph {
/// foo
/// @param numVertex maximum number of vertices allowed
- public MatrixGraph(int numVertex){
+ public MatrixGraph(final int numVertex){
this.numVertex=numVertex;
matrix =new Integer[numVertex][numVertex];
index2vertex=new Vertex[numVertex];
@@ -34,7 +34,7 @@ public class MatrixGraph extends AbstractGraph {
/// foo
/// @param v vertex
/// @return int
- private int getIndex(Vertex v){
+ private int getIndex(final Vertex v){
if(vertex2index.containsKey(v)) return vertex2index.get(v);
int index=vertex2index.size();
if(index>=index2vertex.length)throw new RuntimeException("Too many vertices in graph");
@@ -44,7 +44,7 @@ public class MatrixGraph extends AbstractGraph {
}
/// foo
- public void insertEdge(Vertex v1,Vertex v2,int w){
+ public void insertEdge(final Vertex v1, final Vertex v2, final int w){
matrix[getIndex(v1)][getIndex(v2)] = w;
}
@@ -62,7 +62,7 @@ public class MatrixGraph extends AbstractGraph {
}
/// foo
- public Collection<Edge> outEdge(Vertex v1){
+ public Collection<Edge> outEdge(final Vertex v1){
HashSet<Edge> edges=new HashSet<>();
int i=vertex2index.get(v1);
for(int j=0;j<numVertex;j++){
@@ -74,7 +74,7 @@ public class MatrixGraph extends AbstractGraph {
}
/// foo
- public Integer getWeight(Vertex v1,Vertex v2){
+ public Integer getWeight(final Vertex v1, final Vertex v2){
// constant time operation
return matrix[vertex2index.get(v1)][vertex2index.get(v2)];}
}
diff --git a/src/com.example.portfolio3/com/example/portfolio3/Vertex.java b/src/com.example.portfolio3/com/example/portfolio3/Vertex.java
index 74881a8..caf3930 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/Vertex.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/Vertex.java
@@ -14,7 +14,7 @@ public class Vertex{
/// foo
/// @param s foo
- public Vertex(String s){name=s;}
+ public Vertex(final String s){name=s;}
/// foo
/// @return String
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Control.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Control.java
index 320b36c..1b0e4e5 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Control.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Control.java
@@ -22,7 +22,7 @@ public class Control{
///
/// @param model Application model
/// @param view Application view
- public Control(GUI model, Window view){
+ public Control(final GUI model, final Window view){
this.model = model;
this.view = view;
}
@@ -36,7 +36,7 @@ public class Control{
/// and remaining ones as activity selections
///
/// @param parameters Application parameters
- public void setParameters(List<String> parameters) {
+ public void setParameters(final List<String> parameters) {
boolean optionsDone = false;
boolean studentAssigned = false;
for (String item : parameters) {
@@ -58,7 +58,7 @@ public class Control{
/// Enter activity
///
/// @param s String entered
- public void enterActivity(String s){
+ public void enterActivity(final String s){
model.addActivity(s);
view.clearActivityEntry();
showActivities();
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/GUI.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/GUI.java
index 695c19c..1591f07 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/GUI.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/GUI.java
@@ -22,7 +22,7 @@ public class GUI{
/// Add student
///
/// @param name Name of student
- public void addStudent(String name){
+ public void addStudent(final String name){
student = new Person(name);
}
@@ -36,7 +36,7 @@ public class GUI{
/// Add activity to list
///
/// @param s Activity to add
- public void addActivity(String s){
+ public void addActivity(final String s){
list.add(s);
}
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
index ed38f1d..1382a4a 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Graph.java
@@ -120,7 +120,7 @@ public final class Graph {
/// @param g Graph to inspect
/// @throws IllegalArgumentException
/// https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html
- public static void assertConnected(AbstractGraph g) {
+ public static void assertConnected(final AbstractGraph g) {
// collect all vertices in the graph
Collection<Vertex> c = g.vertices();
@@ -143,7 +143,7 @@ public final class Graph {
///
/// @param g Graph to inspect
/// @return list of disjoint sets
- public static ArrayList<Set<Vertex>> disjoint(AbstractGraph g) {
+ public static ArrayList<Set<Vertex>> disjoint(final AbstractGraph g) {
// get all subject modules
//
@@ -159,7 +159,7 @@ public final class Graph {
/// @param g Graph to inspect
/// @param vip Ordered list of subject modules to prioritize
/// @return List of sets of disjoint choices
- public static ArrayList<Set<Vertex>> disjoint(AbstractGraph g, List<Vertex> vip) {
+ public static ArrayList<Set<Vertex>> disjoint(final AbstractGraph g, final List<Vertex> vip) {
ArrayList<Set<Vertex>> sets = new ArrayList<>();
// track done subject modules as extendable set
@@ -205,7 +205,7 @@ public final class Graph {
/// @param sets list of disjoint choices
/// @param g choices as weights in graph
/// @return groups of disjoint choices as a graph
- public static AbstractGraph moduleGroups(ArrayList<Set<Vertex>> sets, AbstractGraph g) {
+ public static AbstractGraph moduleGroups(final ArrayList<Set<Vertex>> sets, final AbstractGraph g) {
AbstractGraph h = new AdjListGraph();
for (Set<Vertex> s: sets) {
for (Set<Vertex> t: sets) {
@@ -230,7 +230,7 @@ public final class Graph {
///
/// @param g sets of disjoint choices as a graph
/// @return amount of students in consecutive slots
- public static int solution(AbstractGraph g) {
+ public static int solution(final AbstractGraph g) {
// pick a random vertice in the graph
Vertex v = g.vertices().iterator().next();
@@ -243,7 +243,7 @@ public final class Graph {
/// @param g groups of disjoint choices as a graph
/// @param v seed vertex within graph
/// @return amount of students in consecutive slots
- public static int solution(AbstractGraph g, Vertex v) {
+ public static int solution(final AbstractGraph g, final Vertex v) {
return GraphAlgorithms.pathLength(
GraphAlgorithms.dijkstra(g, v));
}
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Main.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Main.java
index 55ae0c1..10092c8 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Main.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Main.java
@@ -65,7 +65,7 @@ public class Main {
///
/// @param args command-line arguments
/// @return choice of UI as String
- public static String uiFromArgs(String[] args) {
+ public static String uiFromArgs(final String[] args) {
// TODO: make "cli" the default when implemented
String defaultUI = "gui";
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Person.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Person.java
index f7eeab3..7435550 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Person.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Person.java
@@ -12,7 +12,7 @@ public class Person {
/// Constructor
///
/// @param name Name of person
- public Person (String name) {
+ public Person (final String name) {
this.name = name;
}
}
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
index ec8b822..475de52 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
@@ -52,12 +52,12 @@ public final class Window extends Application {
/// Application instantiation
///
/// @param args application parameters
- public static void main(String[] args) {
+ public static void main(final String[] args) {
launch(args);
}
@Override
- public void start(Stage stage) {
+ public void start(final Stage stage) {
// pass application parameters to controller
control.setParameters(getParameters().getRaw());
@@ -87,14 +87,14 @@ public final class Window extends Application {
/// action to apply student name
///
/// @param s Text to apply
- public void setStudentName(String s) {
+ public void setStudentName(final String s) {
nameEntry.setText(s);
}
/// action to apply text to area
///
/// @param s Text to apply
- public void setArea(String s) {
+ public void setArea(final String s) {
area.setText(s);
}
@@ -108,7 +108,7 @@ public final class Window extends Application {
/// @param s Label string
/// @param f Text field
/// @return HBox containing styled label and text field
- public HBox ourHBox(String s, TextField f) {
+ public HBox ourHBox(final String s, final TextField f) {
Label label = new Label(s+":");
label.setStyle(LABEL_STYLE);