Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ Challenge #42069

Name: Anonymous 2017-01-23 13:30

Implement a POASTchecker. The POASTchecker will analyse a post number and use heuristic processing to determine whether the number is a /proggles/number, i.e. it will either acknowledge ``dubs'', ``trips'', or ``jackson five GET''. Any reasonable input and output format is allowed.

Good luck!

Name: Anonymous 2017-01-24 15:50

EXPERIENCED ENTERPRISE ARCHITECT SOLUTION

public class Constants {
public static int THE_NUMBER_ZERO = 0;
public static int THE_NUMBER_TWO = 2;
public static int THE_NUMBER_THREE = 3;
public static int THE_NUMBER_FIVE = 5;
public static int THE_NUMBER_TEN = 10;

public static int THE_JACKSON_FIVE_CONSTANT = THE_NUMBER_FIVE;

public static String DUBS_MESSAGE = "DUBS";
public static String TRIPS_MESSAGE = "TRIPS";
public static String JACKSON_FIVE_GET_MESSAGE = "JACKSON FIVE GET";
public static String TRY_AGAIN_NEXT_TIME_MESSAGE = "TRY AGAIN NEXT TIME";
}

public abstract class CheckRule {
public abstract boolean check(int em);
public abstract String congratulations();
}

public abstract class CheckConstantPostNumberRule extends CheckRule {
int theConstantToCheck;

CheckConstantPostNumberRule(int theConstantToCheck) {
this.theConstantToCheck = theConstantToCheck;
}

public boolean check(int em) {
returm em == theConstantToCheck;
}
}

public class JacksonFiveCheckRule extends CheckConstantPostNumberRule {
JacksonFiveCheckRule() {
super(Constants.THE_JACKSON_FIVE_CONSTANT);
}

public String congratulations() {
return Constants.JACKSON_FIVE_GET_MESSAGE;
}
}

public abstract class CheckDubsRule extends CheckRule {
int base;

checkDubsRule(int base) {
this.base = base;
}

boolean check(int em) {
return em % this.base == (em % Math.pow(this.base, Constants.THE_NUMBER_TWO)) / this.base;
}

String congratulations() {
return Constants.DUBS_MESSAGE;
}
}

public class CheckBase10DubsRule extends CheckDubsRule {
CheckBase10DubsRule() {
super(Constants.THE_NUMBER_TEN);
}
}

public abstract class CheckTripsRule extends CheckRule {
int base;
CheckDubsRule dubsCheckerRule;

CheckTripsRule(int base, CheckDubsRule dubsCheckerRule) {
this.base = base;
this.dubsCheckerRule = dubsCheckerRule;
}

boolean check(int em) {
return em%Constants.THE_NUMBER_TEN == (em % Math.pow(this.base, Constants.THE_NUMBER_THREE)) / Math.pow(this.base, Constants.THE_NUMBER_TWO) &&
this.dubsCheckerRule.check(em) && this.dubsCheckerRule.check(em / Constants.THE_NUMBER_TEN);
}

String congratulations() {
return Constants.TRIPS_MESSAGE;
}
}

public class CheckBase10TripsRule extends CheckTripsRule {
CheckBase10DubsRule() {
super(Constants.THE_NUMBER_TEN, new CheckBase10DubsRule());
}
}

public abstract class AbstractPostChecker {
public CheckRule[] checkingRules;

AbstractPostChecker(CheckRule[] checkingRules) {
this.checkingRules = checkingRules;
}

public String check(int em) {
for (int i=Constants.THE_NUMBER_ZERO; i<checkingRules.length; i++)
if (checkingRules[i].check(em))
return checkingRules[i].congratulations();
return Constants.TRY_AGAIN_NEXT_TIME_MESSAGE
}
}

public class POASTChecker extends AbstractPostChecker {
POASTChecker() {
super(new CheckRule[]{new CheckBase10DubsRule(), new CheckBase10TripsRule(),
new JacksonFiveCheckRule()});
}
}

public class POASTCheckerTHE_NUMBER_FIVETest {
public static void main(String[] args) {
POASTChecker thePOASTChecker = new POASTChecker();
System.out.println(thePOASTChecker.check(Constant.THE_NUMBER_FIVE));
}
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List