Part 2: Create a class called Tile that represents a Scrabble tile. The class sh
ID: 3635603 • Letter: P
Question
Part 2: Create a class called Tile that represents a Scrabble tile. The class should contain:• A private character field named letter that holds the letter (or blank) for the tile.
• A private integer field named value that contains the point value for the tile.
• A constructor that creates a tile object with the specified letter/point value combination.
• A method named toString that returns a String represntation of the tile. This should be
the letter, immediately followed by the point value. For example, an A 1 tile would return
“A1”. The X 8 tile would return “X8”.
• A method named getValue( ) that returns the point value of the tile
• A method named setLetter(char c) that sets the letter to the input parameter and returns
void.
Explanation / Answer
class Tile{
private char letter;
private int value;
Tile(char letter,int value){
this.letter=letter;
this.value=value;
}
public void setLetter(char letter){
this.letter=letter;
}
public void setValue(int value){
this.value=value;
}
public char getLetter(){
return this.letter;
}
public int getValue(){
return this.value;
}
public String toString(){
String tilename=letter;
return tilename+value;
}
}