当前位置:天才代写 > JAVA代写,java代考-JAVA作业代写免费Moss检测 > java作业加急 |Data Structure代写 | CharList API string

java作业加急 |Data Structure代写 | CharList API string

2019-09-21 23:59 星期六 所属: JAVA代写,java代考-JAVA作业代写免费Moss检测 浏览:1177

java作业加急 This assignment will require you to write a class to represent
* a resizable array of characters.

package progfund;

import javax.xml.stream.events.Characters;

/**
*

java作业加急
java作业加急

Overview

*

This assignment will require you to write a class to represent
* a resizable array of characters. It should act much like a String.
* Unlike a String however, the characters can be changed or deleted
* directly.

*
*

To make your life easier you will be provided with an API
* specification (just like the JavaDocs you use for your
* programming). Your job is to follow this API to fill out the
* method stubs with appropriate code. You should also ensure that
* this code is uncrashable. If your code detects faulty/incorrect
* input it should handle it as instructed in the Javadoc comments.

*
*

Data Structure

*

We will be storing chars into an array within the CharList
* class. Something to note is that arrays are immutable (They cannot
* be changed once they are created.) A large part of this assignment
* is to add methods to the CharList class to simulate an array that
* is mutable. These methods should allow adding and deleting
* chars from the array and changing the array’s size. Your array
* must always be exactly the size necessary to fit all the
* characters. There must be no null chars on the end.

*

*
*

How To Do The Assignment

*

We suggest you write your code in the order that the methods
* appear in. The most independent methods are listed first.
*
*
*

In general, you may not use methods from other classes. The only
* exceptions are string.length() may be used in your constructor and
* Character.toUpperCase(c) may be used in the toTitleCase() method.
* The use of any other methods may result in a loss of marks.

*
*

For details on what you are actually being marked on, please
* check the Marking Criteria section of the Assignment Specification.
*

*/
public class CharList {
/**
* Array to store chars
*/
private char[] characters = null;

/**
* The instance variable characters will be initialized
* to length 0.
*/
public CharList(){
//TODO
;
this.characters = new characters[0];

}

/**
* The instance variable characters will be initialized to the
* same length and contain the same characters as the argument
* String. If the argument is null, the characters array will be
* length 0.
* @param other The String to copy.
*/
public CharList(String other){
//TODO Write this method as described above then delete this comment
}

/**
* The instance variable characters will be initialized to the
* same length and contain the same characters as the argument
* CharList. If the argument is null, the characters array will
* be length 0.
* @param other the CharList to copy
*/
public CharList(CharList other){
//TODO Write this method as described above then delete this comment
}

/**
* Returns the number of non-null characters in the instance
* variable. Do not count null chars (‘\0’).
* @return The length of the String
*/
public int length(){
//TODO Write this method as described above then delete this comment
return -1;
}

/**
* Compares to CharLists returning true if they contain the same
* chars and are the same length.
* @param other presumed to be a CharList. Must type-cast to
* CharList if it is an instance of this class.
* @return true if both arrays contain the same chars and
* are the same length.
*/
@Override
public boolean equals(Object other){
//TODO Write this method as described above then delete this comment
return false;
}

/**
* Return the char at the argument index from the characters array.
* @param index the position of the char to return.
* @return The char at the given index or ‘\0’ if no char is
* available.
*/
public char charAt(int index){
//TODO Write this method as described above then delete this comment
return ‘\0’;
}

/**
* Returns a new, deep-copy of the instance variable.
* You must use a loop to copy the characters into a new array.
* @return A char array copy of the instance variable, characters.
*/
public char[] toCharArray(){
//TODO Write this method as described above then delete this comment
return null;
}

/**
* Returns a copy of the instance variable as a String.
* You must use a loop to copy the characters into a String.
* @return String representation of the instance variable,
* characters.
*/
@Override
public String toString(){
//TODO Write this method as described above then delete this comment
return null;
}

/**
* Adds each character from the argument CharList to the end of
* this CharList’s characters. The resulting array will replace
* this CharList’s instance variable.
* @param other The CharList to append.
*/
public void append(CharList other){
//TODO Write this method as described above then delete this comment
}

/**
* Adds each character from the argument CharList to the start of
* this CharList’s characters. The resulting array will replace
* this CharList’s instance variable.
* @param other The CharList to prepend.
*/
public void prepend(CharList other){
//TODO Write this method as described above then delete this comment
}

/**
* Adds each character from the argument CharList into this
* CharList’s at the specified index. All characters at that
* index or beyond will be pushed to the end.
*
* If the specified index is equal to the length, it will add
* the characters to the end of the array. If the specified
* index is less than 0 or greater than the length, this method
* does nothing.
* @param other The CharList to insert.
* @param index The position to insert at.
*/
public void insert(CharList other, int index){
//TODO Write this method as described above then delete this comment
}

/**
* Returns the substring in the range from start up to and
* excluding end.
*

Examples:

*

    • *

    • new CharList(“yes”).getRange(1, 1) returns “”

*

    • new CharList(“yes”).getRange(0, 2) returns “ye”

*

    • new CharList(“yes”).getRange(0, 3) returns “yes”

*

    • new CharList(“yes”).getRange(0, 4) returns null

*

* @param start Index of first character.
* @param end Index of the character to stop before.
* @return A CharList representing the chars in this range. If
* start is less than zero, or end is greater than the length
* or start is greater than end, return null.
*/
public CharList getRange(int start, int end){
//TODO Write this method as described above then delete this comment
return null;
}

/**
* Searches through the characters in this CharList for the
* sequence matching the argument CharList. If found, returns
* the index of the first character in the sequence where it was
* found. If it was not found, returns -1.
*
* @param substring Substring to find.
* @param startFrom The index to start looking from.
* @return The index of the first character of the substring or
* -1 if not in the CharList. Also returns -1 if startFrom is
* negative.
*/
public int indexOf(CharList substring, int startFrom){
//TODO Write this method as described above then delete this comment
return -1;
}

/**
* Deletes the char at the argument index. Characters will be
* shifted back to fill in the empty space. The char array will
* be resized to fit only the non-null characters. Any blank
* space must be removed such that “racecar”.deleteChar(3)
* results in the CharList “raccar”. If the index is out of
* bounds, the array will not be changed and the method
* returns -1.
* @param index position of char to delete
* @return true if index is within the bounds of the array
*/
public boolean deleteChar(int index){
//TODO Write this method as described above then delete this comment
return false;
}

/**
* Deletes the substring from start (inclusive) up to
* end (exclusive). The empty space is filled by shifting the
* leftover characters back and resizing the array to fit only
* the characters that are left.
*

Examples:

*

    • *

    • new CharList(“yes”).deleteRange(1, 2) becomes “ys” and
      * returns true

*

    • new CharList(“yes”).deleteRange(0, 2) becomes “s” and
      * returns true

*

    • new CharList(“yes”).getRange(0, 4) stays “yes” and returns
      * false

*

* @param start index of the char to start at
* @param end index of the char to stop before
* @return true if the range was successfully deleted;
* otherwise false.
*/
public boolean deleteRange(int start, int end){
//TODO Write this method as described above then delete this comment
return false;
}

/**
* Deletes the first instance of the argument substring if it is
* found in this CharList. Any blank space must be removed such
* that “racecar”.deleteSubstring(“cec”) results in the CharList
* “raar”
*
* @param substring The string to find.
* @return the index of the first character in the substring that
* was deleted or -1 if the substring was not found.
*/
public int deleteSubstring(CharList substring){
//TODO Write this method as described above then delete this comment
return -1;
}

/**
* Returns the number of instances of substring that are found
* while iterating through the calling object. If the argument
* CharList is null or an empty string, it will return -1.
* @param substring the sequence of characters to find.
* @return The number of times the argument substring was found
* in this CharList or -1 to indicate an error.
*/
public int count(CharList substring) {
//TODO Write this method as described above then delete this comment
return -1;
}

/**
* Creates and returns an array of CharLists where each item is
* a token from this CharList that ends with either the argument
* separator or the end of the CharList.
*

Examples:

*

    • *

    • “you and me”.split(‘ ‘) returns [“you”, “and”, “me”]

*

    • “28/08/1989”.split(‘/’) returns [“28”, “08”, “1989”]

*

    • “aabaa”.split(‘a’) returns [“”, “”, “b”, “”, “”]

*

    • “”.split(‘.’) returns [“”]

*

* @param separator The char to delimit each token.
* @return An array of CharList substrings where each substring
* is delimited by instances of the argument separator.
*/
public CharList[] split(char separator) {
//TODO Write this method as described above then delete this comment
return null;
}

/**
* Capitalizes the first letter of each word in the CharList.
* You may use Character.toUpperCase(chr)
*/
public void toTitleCase(){
//TODO Write this method as described above then delete this comment
}

}

最先出自天才代写 java代写归档
合作:幽灵代写
 

天才代写-代写联系方式