/CustomString

This project was for practicing manipulation of strings and arrays, while studying a java object oriented programming course.

Primary LanguageJava

CustomString

This project was for testing my programming skills in java, while studying a java object oriented programming course.

INSTRUCTIONS

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.

CODE - SOLUTION

You can find the script right here on this repository.

IMPLEMENTATION

Main code for being run

Screenshot from 2023-08-02 11-09-41

Screenshot from 2023-08-02 11-10-01

Output

Screenshot from 2023-08-02 11-10-26