Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

Students also viewed these Databases questions

Question

=+ What typical employee will the IA compare him/

Answered: 1 week ago

Question

=+7 What is the overall cost of the international assignment?

Answered: 1 week ago