Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help creating a JUnit WeekdayTest for my Weekday Class, My Weekday class is listed below: *** Weekday.java *** public enum Weekday { MONDAY, TUESDAY,
Need help creating a JUnit WeekdayTest for my Weekday Class, My Weekday class is listed below:
*** Weekday.java ***
public enum Weekday { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY; public static Weekday fromString(String s) { Weekday value; switch(s.toLowerCase()) { case "monday": case "m": value = Weekday.MONDAY; break; case "tuesday": case "t": value = Weekday.TUESDAY; break; case "wednesday": case "w": value = Weekday.WEDNESDAY; break; case "thursday": case "r": value = Weekday.THURSDAY; break; case "friday": case "f": value = Weekday.FRIDAY; break; default: throw new IllegalArgumentException("String does not match"); } return value; } /** * Provides 1 letter name for the given weekday value */ public String toShortName() { String value = ""; if(Weekday.valueOf("MONDAY") == this) { value = "M"; } else if(Weekday.valueOf("TUESDAY") == this) { value = "T"; } else if(Weekday.valueOf("WEDNESDAY") == this) { value = "W"; } else if(Weekday.valueOf("THURSDAY") == this) { value = "R"; } else if(Weekday.valueOf("FRIDAY") == this) { value = "F"; } return value; } /** * Provides text representation in title case */ public String toString() { String value = ""; if(Weekday.valueOf("MONDAY") == this) { value = "Monday"; } else if(Weekday.valueOf("TUESDAY") == this) { value = "Tuesday"; } else if(Weekday.valueOf("WEDNESDAY") == this) { value = "Wednesday"; } else if(Weekday.valueOf("THURSDAY") == this) { value = "Thursday"; } else if(Weekday.valueOf("FRIDAY") == this) { value = "Friday"; } return value; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started