Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ssn.ssijs.lgh_test17;
- import java.util.HashSet;
- import java.util.Scanner;
- import java.util.Set;
- public class Application {
- Set<String> constraints = new HashSet<>();
- public static void main(String[] args) {
- Depot dep = new Depot(4, 4);
- dep.show();
- Application app = new Application();
- app.run();
- }
- private void run() {
- Scanner scanner = new Scanner(System.in);
- String[] inputConstraints = { "F", "L", "I", "P", "FL", "FI", "FP", "LI", "LP", "IP", "FLI", "FLP", "FIP",
- "LIP", "FLIP" };
- addConstraints(inputConstraints);
- while (true) {
- System.out.println("Put Article:");
- String type = scanner.nextLine();
- type = type.toUpperCase();
- try {
- if (!checkInput(type)) {
- throw new Exception();
- } else {
- System.out.println("Articolul " + type + " este valid");
- }
- } catch (Exception e) {
- System.out.println("Input incorect");
- }
- }
- }
- private boolean checkInput(String type) {
- return constraints.contains(type);
- }
- private void addConstraints(String[] inputConstraints) {
- constraints.clear();
- for (int i = 0; i < inputConstraints.length; i++) {
- constraints.add(inputConstraints[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement