Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Hashtable;
- import java.util.List;
- import java.util.Map;
- public class Dishwasher3 {
- public static void main(String[] args) {
- /** The theory is that that person who filled the dishwasher will empty that on the following day in morning.
- * In this case everyone has to care about it in every third week.*/
- // This is the fillerList below
- // the input list contains the order of the filler guys in the line
- List<String> fillerList = new ArrayList<>();
- fillerList.add("Pratser Frigyes");
- fillerList.add("Kliszki Balint");
- fillerList.add("Torok Daniel");
- fillerList.add("Jason Yeo");
- fillerList.add("Kocsis Daniel");
- fillerList.add("Kiss Mate");
- fillerList.add("Csicsman Sandor");
- fillerList.add("Berki Tamas");
- fillerList.add("Putnoki Nagy Zsolt");
- fillerList.add("Mandi Gergo");
- fillerList.add("Mandi Bence");
- fillerList.add("Bencsik Istvan");
- fillerList.add("Gréczi László");
- // emptierList created that way --> fillerList.get(index) = emptierList.get(index - 1)
- List<String> emptierList = new ArrayList<>();
- emptierList.add(fillerList.get(fillerList.size() - 1));
- for (int i = 0; i < fillerList.size() - 1; i++){
- emptierList.add(fillerList.get(i));
- }
- // 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
- List<String> substituteList = new ArrayList<>();
- int counter1 = 0;
- int counter2 = emptierList.size() / 2 + 1;
- int counter3 = emptierList.size() / 2 + 1;
- while (counter2 < emptierList.size()){
- substituteList.add(emptierList.get(counter2));
- counter2++;
- }
- while (counter1 < counter3){
- substituteList.add(emptierList.get(counter1));
- counter1++;
- }
- // 3 maps created about the defined lists
- Map<Integer, String> mapFiller = new Hashtable<>();
- for (int key = 0; key < fillerList.size(); key++){
- mapFiller.put(key + 1, fillerList.get(key) );
- }
- Map<Integer, String> mapEmptier = new Hashtable<>();
- for (int key = 0; key < emptierList.size(); key++){
- mapEmptier.put(key + 1, emptierList.get(key) );
- }
- Map<Integer, String> mapSubstitute = new Hashtable<>();
- for (int key = 0; key < substituteList.size(); key++){
- mapSubstitute.put(key + 1, substituteList.get(key) );
- }
- // From here the stupid HTML generator follows
- System.out.println("<html>" +
- "<head>" +
- " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
- " <title>dishwasher scheduler</title>\n" +
- " <style>\n" +
- "table {\n" +
- " font-family: arial, sans-serif;\n" +
- " border-collapse: collapse;\n" +
- " width: 100%;\n" +
- "}\n" +
- "\n" +
- "td, th {\n" +
- " border: 1px solid #dddddd;\n" +
- " text-align: left;\n" +
- " padding: 8px;\n" +
- "}\n" +
- "\n" +
- "tr:nth-child(even) {\n" +
- " background-color: #dddddd;\n" +
- "}\n" +
- "</style>" +
- " </head>\n" +
- "\n" +
- "<body>" +
- " <h2>Dishwasher Scheduler</h2>\n" +
- "\n" +
- "<table>\n" +
- " <tr>\n" +
- " <th>Day</th>\n" +
- " <th>Empty</th>\n" +
- " <th>Fill</th>\n" +
- " <th>Substitute</th>\n" +
- " </tr>" +
- "<tr>");
- for (int i = 1; i <= mapFiller.size(); i++) {
- System.out.println("<tr><td>" + i + "</td>" + "<td>" + mapFiller.get(i) + "</td> <td>"
- + mapEmptier.get(i) + "</td> <td> " + mapSubstitute.get(i) + "</td></tr>");
- }
- System.out.println(
- " </body>\n" +
- "</html>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement