Created
June 1, 2016 21:32
-
-
Save authsec/a32b2ff9202b84d135f96e92df68746b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.coffeecrew.examples.enumeration; | |
public class Main { | |
public static void main(String[] args) { | |
for (ProgrammingLanguage pl: ProgrammingLanguage.values()) { | |
printProgrammingLanguage(pl); | |
printMoreAdjacent(ProgrammingLanguage.C, pl); | |
} | |
} | |
public static void printProgrammingLanguage(ProgrammingLanguage pl) { | |
System.out.println(pl); | |
} | |
public static void printMoreAdjacent(ProgrammingLanguage moreAdjacent, | |
ProgrammingLanguage than) { | |
ProgrammingLanguage.Adjacence adj = moreAdjacent.isMoreAdjecent(than); | |
StringBuilder text = new StringBuilder(); | |
text.append(moreAdjacent.name()) | |
.append(" (") | |
.append(moreAdjacent.longName()) | |
.append(")") | |
.append(" is "); | |
switch (adj) { | |
case LESS: | |
text.append(adj.name()); | |
break; | |
case EQUAL: | |
text.append(adj.name()); | |
break; | |
case MORE: | |
text.append(adj.name()); | |
break; | |
default: | |
text.append(adj.name()); | |
} | |
text.append(" hardware adjacent than ") | |
.append(than.name()) | |
.append(" (") | |
.append(than.longName()) | |
.append(")"); | |
System.out.println(text.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment