Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE 110: Principles of Programming Languages Assignment 7 Overvievw In this assignment you will write a program that will implement your own version of String.

image text in transcribed

image text in transcribed

image text in transcribed

CSE 110: Principles of Programming Languages Assignment 7 Overvievw In this assignment you will write a program that will implement your own version of String. Your class will be based around a character array. You will write several methods that mimic String methods and then perform searches within the String, similar to the ones from Assignment Note: You do not have to worry about multiple occurrences of something you are searching for or blank Strings. Requirements Your program must do the following in order to receive full credit on this assignment. 1. Create a class called MyString 2. Make two private instance variables for MyString a. An int, which is the length of the String b. A char array, which is the characters in the String 3. Create a default constructor for MyString which sets the length of the array to C 4. Create a regular constructor which takes a single String parameter and sets this MyString object to be that String This means that the array should be as long as the parameter and each element in the array is one character from the parameter a. 5. Create an boolean method called equals that accepts a String parameter and returns true if the contents of the parameter match the contents of the array a. This should function identically to the equals method from String. b. Hint: Don't forget that String has a toCharArray method and a charAt method. 6. Create an int method called indexOf which takes a char argument and returns the index of the first occurrence of that char in the array a. Again, you do not have to worry about multiple occurrences. b. This should return -1 if the char was not found 7. Overload the indexOf method to create a version which takes a String parameter and retums the index of the start position of the parameter in the char array a. Again, return -1 if it is not in the array b. The whole parameter must be in the array, in order, for this to return an index. i. See Example Outputs

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions