Advertisement
kliba

Dishwasher Scheduler

Mar 25th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.42 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Hashtable;
  3. import java.util.List;
  4. import java.util.Map;
  5.  
  6. public class Dishwasher3 {
  7.  
  8.         public static void main(String[] args) {
  9. /** The theory is that that person who filled the dishwasher will empty that on the following day in morning.
  10.  *  In this case everyone has to care about it in every third week.*/
  11.  
  12.  // This is the fillerList below
  13.  // the input list contains the order of the filler guys in the line
  14.     List<String> fillerList = new ArrayList<>();
  15.      fillerList.add("Pratser Frigyes");
  16.      fillerList.add("Kliszki Balint");
  17.      fillerList.add("Torok Daniel");
  18.      fillerList.add("Jason Yeo");
  19.      fillerList.add("Kocsis Daniel");
  20.      fillerList.add("Kiss Mate");
  21.      fillerList.add("Csicsman Sandor");
  22.      fillerList.add("Berki Tamas");
  23.      fillerList.add("Putnoki Nagy Zsolt");
  24.      fillerList.add("Mandi Gergo");
  25.      fillerList.add("Mandi Bence");
  26.      fillerList.add("Bencsik Istvan");
  27.      fillerList.add("Grรฉczi Lรกszlรณ");
  28.  
  29.  // emptierList created that way --> fillerList.get(index) = emptierList.get(index - 1)
  30.    List<String> emptierList = new ArrayList<>();
  31.      emptierList.add(fillerList.get(fillerList.size() - 1));
  32.      for (int i = 0; i < fillerList.size() - 1; i++){
  33.           emptierList.add(fillerList.get(i));
  34.         }
  35.  
  36.  // this list is a substitute list contains the guys who has to do the filler or emptier job if someone is missing on that day
  37.    List<String> substituteList = new ArrayList<>();
  38.    int counter1 = 0;
  39.    int counter2 = emptierList.size() / 2 + 1;
  40.    int counter3 = emptierList.size() / 2 + 1;
  41.      while (counter2 < emptierList.size()){
  42.        substituteList.add(emptierList.get(counter2));
  43.        counter2++;
  44.      }
  45.      while (counter1 < counter3){
  46.        substituteList.add(emptierList.get(counter1));
  47.        counter1++;
  48.      }
  49.  
  50.  // 3 maps created about the defined lists
  51.   Map<Integer, String> mapFiller = new Hashtable<>();
  52.     for (int key = 0; key < fillerList.size(); key++){
  53.       mapFiller.put(key + 1, fillerList.get(key) );
  54.     }
  55.  
  56.   Map<Integer, String> mapEmptier = new Hashtable<>();
  57.     for (int key = 0; key < emptierList.size(); key++){
  58.       mapEmptier.put(key + 1, emptierList.get(key) );
  59.     }
  60.  
  61.   Map<Integer, String> mapSubstitute = new Hashtable<>();
  62.     for (int key = 0; key < substituteList.size(); key++){
  63.       mapSubstitute.put(key + 1, substituteList.get(key) );
  64.     }
  65.  
  66.   // From here the stupid HTML generator follows
  67.             System.out.println("<html>" +
  68.                     "<head>" +
  69.                     " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
  70.                     " <title>dishwasher scheduler</title>\n" +
  71.                     " <style>\n" +
  72.                             "table {\n" +
  73.                             "    font-family: arial, sans-serif;\n" +
  74.                             "    border-collapse: collapse;\n" +
  75.                             "    width: 100%;\n" +
  76.                             "}\n" +
  77.                             "\n" +
  78.                             "td, th {\n" +
  79.                             "    border: 1px solid #dddddd;\n" +
  80.                             "    text-align: left;\n" +
  81.                             "    padding: 8px;\n" +
  82.                             "}\n" +
  83.                             "\n" +
  84.                             "tr:nth-child(even) {\n" +
  85.                             "    background-color: #dddddd;\n" +
  86.                             "}\n" +
  87.                             "</style>" +
  88.                     " </head>\n" +
  89.                     "\n" +
  90.                     "<body>" +
  91.                     " <h2>Dishwasher Scheduler</h2>\n" +
  92.                     "\n" +
  93.                     "<table>\n" +
  94.                     "  <tr>\n" +
  95.                     "    <th>Day</th>\n" +
  96.                     "    <th>Empty</th>\n" +
  97.                     "    <th>Fill</th>\n" +
  98.                     "    <th>Substitute</th>\n" +
  99.                     "  </tr>" +
  100.                     "<tr>");
  101.                     for (int i = 1; i <= mapFiller.size(); i++) {
  102.                        System.out.println("<tr><td>"  + i + "</td>" + "<td>" + mapFiller.get(i) + "</td> <td>"
  103.                        + mapEmptier.get(i) + "</td> <td> " + mapSubstitute.get(i) + "</td></tr>");
  104.                     }
  105.                     System.out.println(
  106.                     " </body>\n" +
  107.                     "</html>");
  108.   }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement