Skip to content
Snippets Groups Projects
Select Git revision
  • a2f5324a3c8b309a1bf6f6d1060e3993fae4b705
  • master default protected
  • developement_1 protected
  • Version_1.2.4
  • Version_1.2.3
  • Version_1.2.2
  • Version_1.2.1
  • Version_1.2.0
  • Version_1.0.1
  • Version_1.0.0
  • Version_0.1.0
  • Version_0.0.6
  • Version_0.0.5
  • Version_0.0.4
  • Version_0.0.3
  • Version_0.0.2
  • Version_0.0.1
17 results

GeometryEngine.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Main.java 1.25 KiB
    import java.util.*;
    
    public class Main {
        public static void main(String[] args) {
            FunctionalSet<Integer> s = new FunctionalSet<>();
            String line;
            do {
                line = SimpleIO.getString("Enter 'add i', 'remove i', 'min', or 'exit'!");
                String[] words = line.split(" ");
                try {
                    switch (words[0]) {
                    case "exit": break;
                    case "add":
                        s.add(Integer.parseInt(words[1]));
                        System.out.println(s);
                        break;
                    case "remove":
                        s.remove(Integer.parseInt(words[1]));
                        System.out.println(s);
                        break;
                    case "min":
                        System.out.println(s.min(Comparator.<Integer>naturalOrder()));
                        break;
                    default:
                        System.out.println("Unknown command.");
                    }
                } catch (MinimumOfEmptySetException e) {
                    System.out.println("The minimum of the empty set is not defined!");
                } catch (NumberFormatException e) {
                    System.out.println("Failed to parse the number to add/remove.");
                }
            } while (!"exit".equals(line));
        }
    }