Test AP CS
Name________________
Given - String Class
· int compareTo(Object other)
· boolean equals(Object other)
· int length()
· String substring(int from, int to) // returns the substring beginning at from and ending at to -1
· String substring(int from) // returns substring(from, length())
· int indexOf(String s) // returns the index of the first occurrence of s; returns -1 if not found
1. Write a class Name that stores a person's first, middle, and last names and
provides the following methods:
* public Name(String first, String middle, String last) -- constructor. The name
should be stored in the case given; don't convert to all upper or lower case.
* public String getFirst() -- returns the first name
* public String getMiddle() -- returns the middle name
* public String getLast() -- returns the last name
* public String firstMiddleLast() -- returns a string containing the person's full
name in order, e.g., "Mary Jane Smith".
* public String lastFirstMiddle() -- returns a string containing the person's full
name with the last name first followed by a comma, e.g., "Smith, Mary Jane".
* public String initials() -- returns the person's initials (a 3-character string).
public int length() -- returns the total number of characters in the full name,
not including spaces.
* public boolean isPalindrone() returns true if last name is the same backwards
as it is forward for example SMIMS would return true because name is the same front
and backwards. For this function you may assume that all letters in name are capital
letters.
* public void printReverse() would print out the whole name in reverse order
for example Joe Thomas Smith would be printed out as htimSsamohTeoJ
* public String getReverse() would return the whole name reversed as a String
* public int countVowels() returns how many vowels there are in all 3 names for
this problem you may assume that all letters in name are capital.
Make sure that you declare class heading and declare the private variables.