haha this is an intro class but I've got about 30 minutes to fix this code and I'm not sure why it's not compiling, I'll show you what he's asking for and then my code, if you could lead me in the right direction it'd help a lot XD
Overview: The purpose of this project is to give you experience in implementing selection and iteration structures. You will create a class named Phone which will encapsulate a phone number entered as characters and converted to digits.
Often businesses use phone numbers that are mnemonic (contain meaning) to make the number easier to remember such as 1-800-FLOWERS (1-800-356-9377), 1-800-CallAtt (1-800-225-5288), and 1-800-Discover (1-800-347-2683). Notice that some of the “words” are in mixed case and some are longer than 7 characters. The Phone class will contain 2 Strings: one that contains the characters typed in by the user after the 1-800- (in this case FLOWERS, CallAtt, or Discover) which are passed to the constructor as a String and one that contains the characters converted to a phone number also stored in a String (in this case 356-9377, 225-5288, 496-8294, or 347-2683). Notice that the converted numbers contain 7 digits even when the “word” contains more than 7 eligible characters.
Specifications: Code a public class named Phone as described below. As always you are not authorized to add, modify, or remove members of this class.
Data members:
A private String named word.
A private String named number.
Constructor:
A public constructor that takes one String parameter. It initializes word to the parameter. It then calls the setNumber method (see below).
Methods:
setNumber: a private support method that returns nothing and takes no parameters. It should first assign an empty String (“”) to number to avoid the word “null” appearing at the beginning of number. It converts the characters in word to digits and places the digits in number. The conversion is based on the way letters are assigned to the numbers on a telephone: 2 has ABC, 3 has DEF, 4 has GHI, 5 has JKL, 6 has MNO, 7 has PRS, 8 has TUV, and 9 has WXY. Note that Q and Z are not on any key for the purposes of this project. The conversion should not be case sensitive, in other words, the characters ‘a’ and ‘A’ both should be converted to ‘2’ etc. If a character in word is not a letter on a key it should be skipped and not be converted to a digit. number should contain the number of digits as there are eligible characters in word or 7, whichever is less. If number ends up containing more than 3 digits then a hyphen ( - ) should be placed between the third and fourth digits.
toString: a public method that returns number.
My code:
public class Phone
{
private String word;
private String number;
public Phone(String word)
{
setNumber();
}
private int setNumber();
{
return null;
number = String("");
if(word == A, B, C, a, b, or c)
{
number = number + "2";
}
else(word.next == D, E, F, d, e, or f)
{
number = number + "3";
}
else(word.next == G, H, I, g, h, or i)
{
number = number + "4";
}
else(word.next == J, K, L, j, k, or l)
{
number = number + "5";
}
else(word.next == M, N, O, m, n, or o)
{
number = number + "6";
}
else(word.next == P, R, S, p, r, or s)
{
number = number + "7";
}
else(word.next == T, U, V, t, u, or v)
{
number = number + "8";
}
else(word.next == W, X, Y, w, x, or y)
{
number = number + "9";
}
}
public String toString()
{
return number;
}
}
MaxwellGT2000 - "Does the amount of times you beat it count towards how hardcore you are?"
Wii Friend Code - 5882 9717 7391 0918 (PM me if you add me), PSN - MaxwellGT2000, XBL - BlkKniteCecil, MaxwellGT2000







