Class StringImproved
public class StringImproved extends java.lang.Object
This program replaces the string class with a mutable string.
This class represents a character array and provide functionalities need to do basic string processing. It contains an array of characters, representing a textual string.
Overview
In Java, Strings are a great device for storing arrays of characters. One limitation of Strings in Java, however (there is always at least one), is that they are immutable (ie. they cannot be changed once created). Your mission is to create a mutable String Class (called StringImproved) with some clever features. You will also need to ensure that your program is bug free. Your StringImproved Class should be uncrashable as possible. If your code detects faulty/incorrect input it should handle it as instructed in this java API
Data Structure
To make your life easier you will be provided with an API specification (just like the JavaDocs you use for your programming). You must use a char array to store your String in your Class. You are not permitted to use any collection Classes in this assignment. You will need to implement the entire class based on the API specification. This class will encapsulate all the functionality required.
Testing
A test program is also provided for you to use. Please read it carefully as you will be expected to generate your own in assignment 2. Use the test driver as a starting point to test your Class as thoroughly as possible. Note that the marker reserves the right to test more conditions if they think of them.
How to Do The Assignment
I suggest you do your assignment in the following order
Create all the method signatures in the StringImproved Class. Each method should just be blank (with a return null or -1 if necessary).
Compile and make sure that the program works (well, technically it won't because the methods are empty, but make sure it compiles with no error).
Write the constructors. Test.
Write the length method. Test.
Write the charAt method. Test.
Write the endsWith method. Test.
Write the toLowerCase method. Test.
Write the toUpperCase method. Test.
Write the lastIndexOf method. Test.
Write the increaseArray method. Test (note there is no provided test you will need to do it). Write the shrinkArray method. Test (note there is no provided test you will need to do it). Write the contains method. Test.
Write the substring method. Test.
Write the insert method. Test.
Write the append method. Test.
Write the deleteSubString int int method. Test.
Write the deleteSubString string method. Test.
Write the deleteCharAt method. Test. Write the prepend method. Test.
Write the replaceString method. Test.
Write the sort (advanced students) method. Test.
Note that when you add functionality you may have to add test scenarios to other test methods to ensure you have covered all the possibilities.
Additional Requirement.
In addition to what is above there are a number of requirements for this assignment. Most of these are to introduce interesting problems for you to solve and must be obeyed.
As you are programming you will also need to comment your code thoroughly in each of your methods.
Whenever you use a String class (for example passed as a parameter) you can only use the charAt() method of String to get content. Sorry we can't make this too easy. The char array in your structure must always have only the space that is required.
You are not permitted to use any String methods in this class. If you use a String method you will get zero for the offending method. There is one exception you are permitted to use the Strings toCharArray method
Here is the complete prototype of the StringImproved.java class
__________________________________________________________________________________________
public class StringImproved {
private char[] stringArray;
//Write the constructors
public StringImproved() {
stringArray = null;
}
//Write the constructors
public StringImproved(String aString) {
stringArray = aString.toCharArray();
}
//Write the constructors
public StringImproved(char[] stringArray) {
this.stringArray = stringArray;
}
//Write the length method
public int length() {
return -1;
}
//Write the charAt method
public char charAt(int index) {
return '\0';
}
//Write the endsWith method
public char endsWith() {
return '\0';
}
//Write the toLowerCase method
public void toLowerCase() {
}
//Write the toUpperCase method.a
public void toUpperCase() {
}
//Write the lastIndexOf method
public int lastIndexOf(char c) {
return -1;
}
//Write the increaseArray method
public void increaseArray() {
}
//Write the shrinkArray method
public void shrinkArray() {
}
//Write the substring method
public String substring(int begin, int end) {
return "";
}
//Write the substring method
public String substring(int begin) {
return "";
}
//Write the insert method
public void insert(int index, char c) {
}
//Write the append method
public void append(char c) {
}
//Write the deleteSubString string method
public void deleteSubString(String substring) {
}
//Write the deleteSubString int int method
public void deleteSubString(int begin, int end) {
}
//Write the deleteCharAt
public void deleteCharAt(int index) {
}
//prepend method.
public void prepend(char c) {
}
//Write the replaceString method
public void replaceString(String search, String replace) {
}
//Write the sort (advanced students) method
public void sort() {
}
}
Class StringImproved public class StringImproved extends java.lang.Object This program replaces the string class with a mutable...
A java program for this question please! Recursion: A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For example, we would say that the following words are elfish: whiteleaf, tasteful, unfriendly, and waffles, because they each contain those letters. Write a recursive method called elfish(), that, given a word, tells us whether or not that word is elfish. The signature of the method should be: public static boolean elfish(String word)...
Do anyone knows how to write this in java? You are allowed to use the following methods from the Java API: class String length charAt class StringBuilder length charAt append toString class Character any method moveXDownLeft takes a char and a two dimensional array of char as input and returns nothing: The method should find the first occurrence of the char in the array (searching from "top" to "bottom" and "left" to "right"), and it should slide that character...
In Java All methods listed below must be public and static. If your code is using a loop to modify or create a string, you need to use the StringBuilder class from the API. Keep the loops simple but also efficient. Remember that you want each loop to do only one "task" while also avoiding unnecessary traversals of the data. No additional methods are needed. However, you may write additional private helper methods, but you still need to have efficient...
Draw the UML DIAGRAM ALSO
PLEASE DRAW THE UML DIAGRAM.ALSO
in java
should use the program in java
For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class The Point3D class will have the...
How can help me to create this program?
PartADriver
public class PartADriver
{
public static void main (String [] args)
{
// create two martians
Martian m1 = new Martian();
Martian m2 = new Martian("Grey", 3);
// display both martians
Output.showMessage("After instantiation.\n" +
"Martian #1: " + m1.toString() +
"\nMartian #2: " + m2.toString());
// make the first martian speak 3 times
for (int count = 0; count < 3; count++)
m1.speak();
// make the second martian...
*MYST BE I NJAVA* *PLEASE INCORPORATE ALL OF STRING METHODS AND SCANNER METHOD LISTED IN THE DIRECTIONS BELOW* Write a Java class that takes a full name (first and last) as inputted by the user, and outputs the initials. Call the class Initials. The first and last names should be entered on the same input line i.e. there should be only one input to your program. For example, if the name is Jane Doe, the initials outputted will be J...
Question 1[JAVA] Add a method in the Main class named getLines() that takes a filename as a String and returns each line in the file in an array. Have each element of the array be a String. Do not include the newline at the end of each line. Use a BufferedReader object to read the file contents. Note, the contents of input.txt will be different (including the number of lines) for each test case. Example: getLines( "input.txt" ) returns (an...
Java code about writing two methods: public static String randomStringone(int length) public static String randomStringtwo(int length) This method should return a String of random lowercase letters with the given length by using for loops. To generate a random lowercase letter, use a local Random variable and the method nextInt() to generate a number between 97 and 122, then cast the result to a char. The method nextInt() can be found here: https://www.geeksforgeeks.org/java-util-random-nextint-java/ In randomStringone(), you should use String concatenation...
I need help with this
Mammal:
public class Mammal extends Pet{
String Vaccination="";
public Mammal(String name, String parent, String
species, String birthday, String Vaccination) {
//Accessing
the super class Constructor and setting the variables.
super(name,parent,species, birthday);
this.Vaccination=Vaccination;
} // end Mammal
public String getVaccination() {
return
Vaccination;
} // end getVaccination
public void setVaccination(String
Vaccination) {
this.Vaccination =
Vaccination;
} // end setVaccination
@Override
public String toString() {
return
super.toString()+". This Mammal requires following vaccinations "+
Vaccination;
} // end...
In this assignment you will create two Java programs: The first program will be a class that holds information (variables) about an object of your choice and provides the relevant behavior (methods) The second program will be the main program which will instantiate several objects using the class above, and will test all the functions (methods) of the class above. You cannot use any of the home assignments as your submitted assignment. Your programs must meet the following qualitative and...