Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package hw2; /** * A class that mimics how Java's String class behaves. */ public class MyString { private char[] data; /** * Construcs a

package hw2;

/**

* A class that mimics how Java's String class behaves.

*/

public class MyString {

private char[] data;

/**

* Construcs a MyString object to represent the text in

* string

* @param string the String we are representing.

*/

public MyString(String string) {

// TODO

}

/**

* A lexicographical comparison of this Mystring to other.

* The comparison is case sensitive, meaning it might not return the correct answer

* if the text being compared isn't all the same case.

*

* @param other the MyString to compare against.

* @return a negative number if this appears before other

* in the dictionary, a positive number if this appears after

* other in the dictonary, and 0 if this and other

* represent the same String

*/

public int compareTo(MyString other) {

// TODO

return 0;

}

public char charAt(int i) {

// TODO

return '\0';

}

public int length() {

// TODO

return -1;

}

public int indexOf(char c) {

// TODO

return -2;

}

@Override

public boolean equals(Object obj) {

// TODO

return false;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

More Books

Students also viewed these Databases questions

Question

10.

Answered: 1 week ago