Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Attached is the UML diagram and the interface. Thx! Develop a Java class called RamString that correctly implements the WackyStringinterface that is provided (The semantics

Attached is the UML diagram and the interface. Thx!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Develop a Java class called RamString that correctly implements the WackyStringinterface that is provided (The semantics of the methods in the interface should be obvious from their name and from the Javadoc comments in the code. If not, please ask for clarification) The RamString class should be designed so that instance variables are never NULL. Important note: This project is focused on character and String manipulation and you are not allowed to use regular expressions or any classes or methods that make us of regular expressions Write a test driver for class RamString called RamStringTester. Specifically, you should create several different test cases for each method of in the interface. Each test should be a separate method. Make sure that the tests are not trivial (i.e., have a specific purpose). In other words, each test should (1) test a specific piece of functionality and (2) check that such piece of functionality behaves as expected. In addition, at least two of the tests for method convertDigitsToRomanNumeralsInSubstring should result in expected exceptions MylndexOutOfBoundsException (provided) in one case, and IllegalArgumentException in the other. Add a concise comment to each test that you implement to clarify its rationale (e.g., "This test checks whether method convertDigitsToRomanNumeralslnSubstring suitably throws an IllegalArgumentException if startPosition is greater than endPosition"). Please note the tests you are creating are not Junit test cases. It is expected that all tests defined in the RamStringTester class will be called in its main method and the output of each test printed to the console Notes: You cannot modify the provided interface, WackyStringlnterface You must use the provided MylndexOutOFBoundsException class I will run your code against a standard set of test cases to make sure that you implemented the functionality of the required methods correctly Comment out or remove any package statements from the files that you submit to Blackboard Write this program in JAVA and compile it in JDK 8 or better. Follow all commenting conventions discussed in class and include a comment block at the top of each file with your name, date, the course number and section. In addition, the comment block at the top of the tester class must include a description of the program purpose, input, and output. It is expected that your program will be well documented and you are required to include a private helper method in your driver called printHeading that outputs the following information to the console in an easy-to-read format: your name, the project number, the course identifier, and the current semester. You will call this method as the first statement in your main method RamString class: Instance data member is private (5 pts.) Constructors are implemented as specified (5 pts.]) Appropriate accessor and mutator methods included (5 pts.) getEvenCharacters () method written as specified (10 pts.) getOddCharacters () method written as specified (10 pts.) countNonDigits) method written as specified (10 pts.) isValidEmail) method written as specified (10 pts.) ramifyString() method written as specified (10 pts.) convertDigitsToRomanNumeralsinSubstring () method written as specified (10 pts.) class: printHeadingl) method included and called from main() (5 pts.) All methods of RamString are tested (10 pt.) Files are named and submitted as specified (5 pts.) Appropriate use of comments (including header comments on all files) (5 pts.) > WackyStringlnterface (default package) o setWackyString(String):void o getWackyString):String o getEvenCharacters:String o getOddCharacters):String o countNonDigits():int o isValidEmail):boolean o ramifyString) void o convertDigitsToRomanNumeralsinSubstring(int,int):void > GRamString (default package) a current: String RamString(String) o setWackyString(String):void o getWackyString():String o getEvenCharacters():String o getOddCharacters):String o countNonDigits():int o isValidEmail):boolean o ramifyString) void o convertDigitsToRomanNumeralsinSubstring(int,int):void * This is an interface for a simple class that represents a string, defined * as a sequence of characters public interface WackyStringInterface * Sets the value of the current string. * @param string The value to be set void setWackyString(String string); * Returns the current string * return Current string String getwackyString(); * Returns a string that consists of al1 and only the characters * in even positions (i.e., second, fourth, sixth, and so on) in * the current string, in the same order and with the same case as * in the current string. The first character in the string is * considered to be in Position 1. @return String made of characters in even positions in the * current string String getEvenCharacters ); * Returns a string that consists of al1 and only the characters * in odd positions (i.e., first, third, fifth, and so on) in the * current string, in the same order and with the same case as in the current string. The first character in the string is * considered to be in Position 1. @return String made of characters in odd positions in the * current string String getOddCharacters); * Returns the number of characters that are not digits * in the current string * return Number of non-digits in the current string int countNonDigits); * Returns true if the current string contains on or more characters * before ancharacter, followed by one or more characters, then * an '.' character and one or more characters. For example, RodneyTheRam@vcu.edu a valid email address. *Returns false otherwise. @return String made of characters in odd positions in the * current string String getOddCharacters(); * Returns the number of characters that are not digits * in the current string * return Number of non-digits in the current string int countNonDigits); * Returns true if the current string contains on or more characters * before ancharacter, followed by one or more characters, then * an .' character and one or more characters. For example, RodneyTheRam@vcu.edu a valid email address. * Returns false otherwise. @return true if current string is formated as an email address boolean isValidEmail Replace all occurence of a single zero (0) with the string "Rams" *in the current string, * and all occurence of a double zero (00) with the string "VCU" void ramifyString); * Replace the individual digits in the current string, between * startPosition and endPosition (included), with the corresponding * Roman numeral symbol(s). The first character in the string is * considered to be in Position 1. Digits are converted individually, * even if contiguous, and digit "O" is not converted (e.g., 460 is converted to IWI0) In case you are not familiar with Roman * numerals, see https://en.wikipedia.org/wiki/Roman_numerals * @param startPosition * param endPosition * @throws MyIndexoutofBoundsException Position of the first character to consider Position of the last character to consider If either "startPosition" or "endPosition" are out of bounds (i.e., either less than 1 or greater then the length of the string) * @throws IllegalArgumentException If "startPosition>"endPosition" (but both are within bounds) void convertDigitsToRomanNumeralsInSubstring(int startPosition, int endPosition) throws MyIndexOutofBoundsException, IllegalArgumentException; Develop a Java class called RamString that correctly implements the WackyStringinterface that is provided (The semantics of the methods in the interface should be obvious from their name and from the Javadoc comments in the code. If not, please ask for clarification) The RamString class should be designed so that instance variables are never NULL. Important note: This project is focused on character and String manipulation and you are not allowed to use regular expressions or any classes or methods that make us of regular expressions Write a test driver for class RamString called RamStringTester. Specifically, you should create several different test cases for each method of in the interface. Each test should be a separate method. Make sure that the tests are not trivial (i.e., have a specific purpose). In other words, each test should (1) test a specific piece of functionality and (2) check that such piece of functionality behaves as expected. In addition, at least two of the tests for method convertDigitsToRomanNumeralsInSubstring should result in expected exceptions MylndexOutOfBoundsException (provided) in one case, and IllegalArgumentException in the other. Add a concise comment to each test that you implement to clarify its rationale (e.g., "This test checks whether method convertDigitsToRomanNumeralslnSubstring suitably throws an IllegalArgumentException if startPosition is greater than endPosition"). Please note the tests you are creating are not Junit test cases. It is expected that all tests defined in the RamStringTester class will be called in its main method and the output of each test printed to the console Notes: You cannot modify the provided interface, WackyStringlnterface You must use the provided MylndexOutOFBoundsException class I will run your code against a standard set of test cases to make sure that you implemented the functionality of the required methods correctly Comment out or remove any package statements from the files that you submit to Blackboard Write this program in JAVA and compile it in JDK 8 or better. Follow all commenting conventions discussed in class and include a comment block at the top of each file with your name, date, the course number and section. In addition, the comment block at the top of the tester class must include a description of the program purpose, input, and output. It is expected that your program will be well documented and you are required to include a private helper method in your driver called printHeading that outputs the following information to the console in an easy-to-read format: your name, the project number, the course identifier, and the current semester. You will call this method as the first statement in your main method RamString class: Instance data member is private (5 pts.) Constructors are implemented as specified (5 pts.]) Appropriate accessor and mutator methods included (5 pts.) getEvenCharacters () method written as specified (10 pts.) getOddCharacters () method written as specified (10 pts.) countNonDigits) method written as specified (10 pts.) isValidEmail) method written as specified (10 pts.) ramifyString() method written as specified (10 pts.) convertDigitsToRomanNumeralsinSubstring () method written as specified (10 pts.) class: printHeadingl) method included and called from main() (5 pts.) All methods of RamString are tested (10 pt.) Files are named and submitted as specified (5 pts.) Appropriate use of comments (including header comments on all files) (5 pts.) > WackyStringlnterface (default package) o setWackyString(String):void o getWackyString):String o getEvenCharacters:String o getOddCharacters):String o countNonDigits():int o isValidEmail):boolean o ramifyString) void o convertDigitsToRomanNumeralsinSubstring(int,int):void > GRamString (default package) a current: String RamString(String) o setWackyString(String):void o getWackyString():String o getEvenCharacters():String o getOddCharacters):String o countNonDigits():int o isValidEmail):boolean o ramifyString) void o convertDigitsToRomanNumeralsinSubstring(int,int):void * This is an interface for a simple class that represents a string, defined * as a sequence of characters public interface WackyStringInterface * Sets the value of the current string. * @param string The value to be set void setWackyString(String string); * Returns the current string * return Current string String getwackyString(); * Returns a string that consists of al1 and only the characters * in even positions (i.e., second, fourth, sixth, and so on) in * the current string, in the same order and with the same case as * in the current string. The first character in the string is * considered to be in Position 1. @return String made of characters in even positions in the * current string String getEvenCharacters ); * Returns a string that consists of al1 and only the characters * in odd positions (i.e., first, third, fifth, and so on) in the * current string, in the same order and with the same case as in the current string. The first character in the string is * considered to be in Position 1. @return String made of characters in odd positions in the * current string String getOddCharacters); * Returns the number of characters that are not digits * in the current string * return Number of non-digits in the current string int countNonDigits); * Returns true if the current string contains on or more characters * before ancharacter, followed by one or more characters, then * an '.' character and one or more characters. For example, RodneyTheRam@vcu.edu a valid email address. *Returns false otherwise. @return String made of characters in odd positions in the * current string String getOddCharacters(); * Returns the number of characters that are not digits * in the current string * return Number of non-digits in the current string int countNonDigits); * Returns true if the current string contains on or more characters * before ancharacter, followed by one or more characters, then * an .' character and one or more characters. For example, RodneyTheRam@vcu.edu a valid email address. * Returns false otherwise. @return true if current string is formated as an email address boolean isValidEmail Replace all occurence of a single zero (0) with the string "Rams" *in the current string, * and all occurence of a double zero (00) with the string "VCU" void ramifyString); * Replace the individual digits in the current string, between * startPosition and endPosition (included), with the corresponding * Roman numeral symbol(s). The first character in the string is * considered to be in Position 1. Digits are converted individually, * even if contiguous, and digit "O" is not converted (e.g., 460 is converted to IWI0) In case you are not familiar with Roman * numerals, see https://en.wikipedia.org/wiki/Roman_numerals * @param startPosition * param endPosition * @throws MyIndexoutofBoundsException Position of the first character to consider Position of the last character to consider If either "startPosition" or "endPosition" are out of bounds (i.e., either less than 1 or greater then the length of the string) * @throws IllegalArgumentException If "startPosition>"endPosition" (but both are within bounds) void convertDigitsToRomanNumeralsInSubstring(int startPosition, int endPosition) throws MyIndexOutofBoundsException, IllegalArgumentException

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions