In this assignment, you will implement a simple class called CustomString. This class represents a more customizable version of a String, with additional attributes and methods. For example, the CustomString class has a "reverse" method which returns a new string version of the current string where the capitalization is reversed (ie, lowercase to uppercase and uppercase to lowercase) for the alphabetical characters specified in a given argument. For CustomString "abc., XYZ: 123.", calling reverse("bcdxyz@3210.") will return "aBC, xyz: 123.". The CustomString class also has a "remove" method which returns a new string version of the current string where the alphabetical characters specified in a given argument, are removed. For CustomString "my lucky numbers are 6, 8, and 19.". calling remove("ra6") will return "my lucky numbers e 6, 8, nd 19.". There are 5 methods that need to be implemented in the CustomString class: getString) - Returns the current string setString(String string) - Sets the value of the current string. remove(String arg) - Returns a new string version of the current string where the alphabetical characters specified in the given arg, are removed. • reverse(String arg) - Returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase, and uppercase to lowercase) for the alphabetical characters specified in the given arg. • filterLetters(char n, boolean more) - Returns a new string version of the current string where all the letters either >= or cs the given char n, are removed.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
Please Use Java only. In this assignment, you will implement a simple class called ​CustomString​. This class represents a more customizable version of a String, with additional attributes and methods. For example, the CustomString class has a “reverse” method which returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase and uppercase to lowercase) for the alphabetical characters specified in a given argument. For CustomString “abc, XYZ; 123.”, calling reverse("bcdxyz@3210.") will return "aBC, xyz; 123.". The CustomString class also has a “remove” method which returns a new string version of the current string where the alphabetical characters specified in a given argument, are removed. For CustomString "my lucky numbers are 6, 8, and 19.", calling remove("ra6") will return "my lucky numbers e 6, 8, nd 19.". There are 5 methods that need to be implemented in the CustomString class: ● getString() - Returns the current string. ● setString(String string) - Sets the value of the current string. ● remove(String arg) - Returns a new string version of the current string where the alphabetical characters specified in the given arg, are removed. ● reverse(String arg) - Returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase, and uppercase to lowercase) for the alphabetical characters specified in the given arg. ● filterLetters(char n, boolean more) - Returns a new string version of the current string where all the letters either >= or operators. For example: char myChar1 = ‘s’; char myChar2 = ‘t’; //compared is true boolean compared = myChar1 < myChar2;
The Assignment
In this assignment, you will implement a simple class called CustomString. This class
represents a more customizable version of a String, with additional attributes and methods.
For example, the CustomString class has a "reverse" method which returns a new string
version of the current string where the capitalization is reversed (i.e., lowercase to uppercase
and uppercase to lowercase) for the alphabetical characters specified in a given argument For
CustomString "abc, XYZ; 123.", calling reverse("bcdxyz@3210.") will return "aBC, xyz: 123.".
The CustomString class also has a "remove" method which returns a new string version of the
current string where the alphabetical characters specified in a given argument, are removed.
For CustomString "my lucky numbers are 6, 8, and 19.", calling remove("ra6") will return "my
lucky numbers e 6, 8, nd 19.",
There are 5 methods that need to be implemented in the CustomString class:
getString() - Returns the current string.
• setString(String string) - Sets the value of the current string.
• remove(String arg) - Returns a new string version of the current string where the
alphabetical characters specified in the given arg, are removed.
• reverse(String arg) - Returns a new string version of the current string where the
capitalization is reversed (i.e., lowercase to uppercase, and uppercase to lowercase) for
the alphabetical characters specified in the given arg.
• filterLetters(char n, boolean more) - Returns a new string version of the current string
where all the letters either >= or <= the given char n, are removed.
Penn
Engineering
TONLINE LEARNING
Introduction to Java & Object Oriented Programming
Each method has been defined for you, but without the code. See the javadoc for each method
for instructions on what the method is supposed to do and how to write the code. It should be
clear enough. In some cases, we have provided hints and example method calls to help you
get started.
For example, we have defined a "setString" method for you (see below) which sets the value of
the current string. Read the javadoc, which explains what the method is supposed to do. Then
write your code where it says "II TODO" to implement the method. You'll do this for each
method in the program.
/**
* Sets the value of the current string.
* eparam string value to be set
public void setString (String string) {
// TODO Implement method
In addition, you will write unit tests to test your method implementations. Each unit test
method has been defined for you, including some test cases. First make sure you pass all of
the provided tests, then write additional and distinct test cases for each unit test method.
For example, we have defined a "testSetString" method for you (see below) which tests the
"setString" method. Pass the tests provided then write additional tests where it says "I
TODO". You'll do this for each unit test method in the program.
@Test
void testSetString () (
//string should be null to start, before setting it
assertNull (this.myCustomstring.getString ()):
this.myCustomString.setString ("Good-bye!"):
assertEquals ("Good-bye!", this.myCustomstring.getString ());
// TODO write at least 3 additional test cases
Tips for this Assignment
In this assignment, some tips are given as follows:
APenn
Engineering
Transcribed Image Text:The Assignment In this assignment, you will implement a simple class called CustomString. This class represents a more customizable version of a String, with additional attributes and methods. For example, the CustomString class has a "reverse" method which returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase and uppercase to lowercase) for the alphabetical characters specified in a given argument For CustomString "abc, XYZ; 123.", calling reverse("bcdxyz@3210.") will return "aBC, xyz: 123.". The CustomString class also has a "remove" method which returns a new string version of the current string where the alphabetical characters specified in a given argument, are removed. For CustomString "my lucky numbers are 6, 8, and 19.", calling remove("ra6") will return "my lucky numbers e 6, 8, nd 19.", There are 5 methods that need to be implemented in the CustomString class: getString() - Returns the current string. • setString(String string) - Sets the value of the current string. • remove(String arg) - Returns a new string version of the current string where the alphabetical characters specified in the given arg, are removed. • reverse(String arg) - Returns a new string version of the current string where the capitalization is reversed (i.e., lowercase to uppercase, and uppercase to lowercase) for the alphabetical characters specified in the given arg. • filterLetters(char n, boolean more) - Returns a new string version of the current string where all the letters either >= or <= the given char n, are removed. Penn Engineering TONLINE LEARNING Introduction to Java & Object Oriented Programming Each method has been defined for you, but without the code. See the javadoc for each method for instructions on what the method is supposed to do and how to write the code. It should be clear enough. In some cases, we have provided hints and example method calls to help you get started. For example, we have defined a "setString" method for you (see below) which sets the value of the current string. Read the javadoc, which explains what the method is supposed to do. Then write your code where it says "II TODO" to implement the method. You'll do this for each method in the program. /** * Sets the value of the current string. * eparam string value to be set public void setString (String string) { // TODO Implement method In addition, you will write unit tests to test your method implementations. Each unit test method has been defined for you, including some test cases. First make sure you pass all of the provided tests, then write additional and distinct test cases for each unit test method. For example, we have defined a "testSetString" method for you (see below) which tests the "setString" method. Pass the tests provided then write additional tests where it says "I TODO". You'll do this for each unit test method in the program. @Test void testSetString () ( //string should be null to start, before setting it assertNull (this.myCustomstring.getString ()): this.myCustomString.setString ("Good-bye!"): assertEquals ("Good-bye!", this.myCustomstring.getString ()); // TODO write at least 3 additional test cases Tips for this Assignment In this assignment, some tips are given as follows: APenn Engineering
Tips for this Assignment
In this assignment, some tips are given as follows:
Penn
Engineering
ONLINE LEARNING
Introduction to Java & Object Oriented Programming
Converting a String to an array of chars in Java:
o Use the "toCharArray()" method of a String
For example:
String myString = "hello";
//arrayofChars contains 'h', 'e', 'l', 'l', 'o'
Char[] arrayOfChars = myString.toCharArray();
Checking whether a specified char value is a letter in Java:
o Use "Character.isLetter(char)"
For example:
//isLetter is true
boolean isLetter = Character.isLetter ('t');
Checking whether a specified char value is uppercase in Java:
o Use "Character.isUpperCase(char)"
For example:
//isUpperCase is true
boolean isUpperCase = Character.isUpperCase ('T');
Checking whether a specified char value is lowercase in Java:
o Use "Character.isLowerCase(char)"
For example:
//isLowerCase is true
boolean isLowerCase = Character.isLowerCase ('t');
Converting a character to uppercase in Java:
o Use "Character.toUpperCase(char)"
For example:
//myChar is 'T'
char myChar
Converting a character to lowercase in Java:
haracter.toUpperCase ('t');
Use "Character.toLowerCase(char)"
For example:
//myChar is t'
char myChar = Character.toLowerCase ('T');
Comparing characters in Java:
You can compare characters like you compare numbers using ==, <, and >
operators.
For example:
's' ;
char myCharl =
char myChar2 =
't';
//compared is true
boolean compared = myCharl < myChar2;
Transcribed Image Text:Tips for this Assignment In this assignment, some tips are given as follows: Penn Engineering ONLINE LEARNING Introduction to Java & Object Oriented Programming Converting a String to an array of chars in Java: o Use the "toCharArray()" method of a String For example: String myString = "hello"; //arrayofChars contains 'h', 'e', 'l', 'l', 'o' Char[] arrayOfChars = myString.toCharArray(); Checking whether a specified char value is a letter in Java: o Use "Character.isLetter(char)" For example: //isLetter is true boolean isLetter = Character.isLetter ('t'); Checking whether a specified char value is uppercase in Java: o Use "Character.isUpperCase(char)" For example: //isUpperCase is true boolean isUpperCase = Character.isUpperCase ('T'); Checking whether a specified char value is lowercase in Java: o Use "Character.isLowerCase(char)" For example: //isLowerCase is true boolean isLowerCase = Character.isLowerCase ('t'); Converting a character to uppercase in Java: o Use "Character.toUpperCase(char)" For example: //myChar is 'T' char myChar Converting a character to lowercase in Java: haracter.toUpperCase ('t'); Use "Character.toLowerCase(char)" For example: //myChar is t' char myChar = Character.toLowerCase ('T'); Comparing characters in Java: You can compare characters like you compare numbers using ==, <, and > operators. For example: 's' ; char myCharl = char myChar2 = 't'; //compared is true boolean compared = myCharl < myChar2;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT