diff options
Diffstat (limited to 'dk/abcdefghijklmnopqrstuvxyzæøå/bachelorizer/Control.java')
-rw-r--r-- | dk/abcdefghijklmnopqrstuvxyzæøå/bachelorizer/Control.java | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/dk/abcdefghijklmnopqrstuvxyzæøå/bachelorizer/Control.java b/dk/abcdefghijklmnopqrstuvxyzæøå/bachelorizer/Control.java deleted file mode 100644 index 09019e4..0000000 --- a/dk/abcdefghijklmnopqrstuvxyzæøå/bachelorizer/Control.java +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk> -// SPDX-License-Identifier: GPL-3.0-or-later - -package dk.abcdefghijklmnopqrstuvxyzæøå.bachelorizer; - -import java.util.List; - -import dk.abcdefghijklmnopqrstuvxyzæøå.bachelorizer.model.GUI; -import dk.abcdefghijklmnopqrstuvxyzæøå.bachelorizer.view.Window; - -/// Bachelorizer - Controller -public class Control{ - - /// Application model - // (declared explicitly only to silence javadoc) - private GUI model; - - /// Application view - private Window view; - - /// Parameters passed on command-line and in JNLP file - private List<String> parameters; - - /// Default constructor - /// - /// @param model Application model - /// @param view Application view - public Control(GUI model, Window view){ - this.model = model; - this.view = view; - } - - /// parse application parameters - /// - /// parse parameters as GNU-style options and arguments, - /// i.e. treat dash-prefixed words as options - /// until an optional first bare "--", - /// taking first non-option argument as name of student - /// and remaining ones as activity selections - /// - /// @param parameters Application parameters - public void setParameters(List<String> parameters) { - boolean optionsDone = false; - boolean studentAssigned = false; - for (String item : parameters) { - if (!optionsDone && item.matches("--")) { - optionsDone = true; - } else if (!item.startsWith("-")) { - if (!studentAssigned) { - model.addStudent(item); - studentAssigned = true; - showStudent(); - } else { - model.addActivity(item); - showActivities(); - } - } - } - } - - /// Enter activity - /// - /// @param s String entered - public void enterActivity(String s){ - model.addActivity(s); - view.clearActivityEntry(); - showActivities(); - } - - /// Display student - public void showStudent() { - view.setStudentName(model.getStudentName()); - } - - /// Display list of activity entries - public void showActivities() { - String toarea = ""; - for (String t : model.getActivities()) - toarea += t + "\n"; - view.setArea(toarea); - } - - /// drop last activity entry - public void delOne(){ - model.delOneActivity(); - showActivities(); - } - - /// drop all activity entries - public void delAll(){ - model.delAllActivities(); - showActivities(); - } -} |