Question: Problem 1 1. In the main/java directory, create a class named MyString that has the following: A private (i.e. encapsulated) String instance variable named original.

Problem 1

1. In the main/java directory, create a class named MyString that has the following:

  • A private (i.e. encapsulated) String instance variable named original.
  • A constructor that takes one String parameter and sets the instance variable.
  • A getter for the instance variable.
    • Uncomment the test named shouldInitializeInstanceVariable in the MyStringTest class (in the test/java directory). Run the test. Run the code analyzers and commit your code now.
  • A method named removeVowels that does not take any parameters and returns a String. This method should remove the vowels (a/A, e/E, i/I, o/O, u/U) from original and return a String composed of just the consonants with their order preserved. You may not use any String methods other than: length, charAt, equals, indexOf
    • Uncomment the tests beginning with removeVowels... in the MyStringTest class (in the test/java directory). Run the tests. Run the code analyzers and commit your code now.
  • A method named removeNonVowels that does not take any parameters and returns a String. This method should remove everything that is not a vowel (not a/A, e/E, i/I, o/O, u/U) from original and return a String composed of just the vowels with their order preserved. You may not use any String methods other than: length, charAt, equals, indexOf
    • Uncomment the tests beginning with removeNonVowels... in the MyStringTest class (in the test/java directory). Run the tests. Run the code analyzers and commit your code now.

Note. To help you debug and understand your code, you can create a MyStringDemo class with the main method, but it is not required as part of your grade.

Problem 2

1. In the main/java directory, create a class named StringInfo. It should include the following:

  • A private (i.e. encapsulated) String instance variable named letters.
  • A constructor that takes one String parameter and sets the instance variable.
  • A getter for the instance variable.
    • Uncomment the test named shouldInitializeInstanceVariable in the StringInfoTest class (in the test/java directory). Run the test. Run the code analyzers and commit your code now.
  • A method named moreThanThree that takes a char type as a parameter and returns a boolean. This method should return true if the parameter occurs more than 3 times in the letters instance variable and false otherwise. You may not use a loop in your code, and you may not use any String methods other than: length, charAt, equals, indexOf
    • Uncomment the tests beginning with moreThanThree... in the StringInfoTest class (in the test/java directory). Run the tests. Run the code analyzers and commit your code now.

Note. To help you debug and understand your code, you can create a StringInfoDemo class with the main method, but it is not required as part of your grade.

Problem 3

1. In the main/java directory, create a class named StringManipulation. It should include the following:

  • A private default constructor that does nothing (i.e. it is empty).
    • Uncomment the test beginning with constructor... in the StringManipulation class (in the test/java directory). Run the test. Run the code analyzers and commit your code now.
  • A method named areRelated that takes three Strings as parameters and returns a boolean. Should this method be an instance method or a static method? Why? This method should return true any one of the characters from the first parameter can be appended to the end second parameter to turn it into the third parameter. If not, the method should return false. For example, if the first parameter has the value "pan", the second parameter has the value "alumn", and the third parameter has the value "alumna", then the method would return true because an a can be appended to alumn to produce alumna. You may not use any String methods other than: length, charAt, equals, indexOf
    • Uncomment the tests beginning with areRelated... in the StringManipulation class (in the test/java directory). Run the tests. Run the code analyzers and commit your code now.

Note. To help you debug and understand your code, you can create a StringManipulationDemo class with the main method, but it is not required as part of your grade.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!