1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Karolina [17]
3 years ago
14

Create a class named Tile that represents Scrabble tiles. The instance variables should include a String named letter and an int

eger named value. Write a constructor that takes parameters named letter and value and initializes the instance variables. Write a method named printTile that takes a Tile object as a parameter and displays the instance variables (letter and value) in a reader-friendly format. Using a Driver class create a Tile object with the letter Z and the value 10, and then uses printTile to display the state of the object. Create getters and setters for each of the attributes.

Computers and Technology
1 answer:
katrin [286]3 years ago
5 0

Answer:

Here is the Tile class:

class Tile {   //class name  

// declare private data members of Tile class

  private int value;  //int type variable to hold the integer

  private String letter;     //String type variable to hold the letter

  public void setValue(int value){  //mutator method to set the integer value

       this.value = value;    }

   public void setLetter(String letter){   //mutator method to set the letter

       this.letter = letter;    }

   public int getValue()   //accessor method to access or get the value

     {return value;}  //returns the current integer value

   

   public String getLetter()   //accessor method to access or get the letter

      {return letter;}     //returns the current string value

   

   public Tile(String letter, int value){   //constructor that takes parameters named letter and value

     setValue(value);  //uses setValue method to set the value of value field

     setLetter(letter);   }  }  //uses setValue method to set the value of letter field

/* you can also use the following two statements inside constructor to initializes the variables:

this.letter = letter;

this.value = value; */

Explanation:

Here is the driver class named Main:

public class Main{  //class name

public static void main(String[] args) { //start of main method  

           Tile tile = new Tile("Z", 10); //creates object of Tile class named tile and calls Tile constructor to initialize the instance variables  

       printTile(tile); } //calls printTile method by passing Tile object as a parameter

public static void printTile(Tile tile) { //method to displays the instance variables (letter and value) in a reader-friendly format

 System.out.println("The tile " + tile.getLetter() + " has the score of " + tile.getValue()); }  } //displays the string letter and integer value using getLetter() method to get the letter and getValue method to get the value

The screenshot of the output is attached.

You might be interested in
Which of the following is an example of new and emerging classes of software?
Rama09 [41]
The answer is Smart technology :)
4 0
3 years ago
You must receive an invitation in order to join Pinterest. True or False?
malfutka [58]
That is false, Pinterest is a free website that anyone can join!
3 0
3 years ago
Read 2 more answers
What is the meaning of web browser
anastassius [24]
Is that a joke... if ain't cheatin you repeatin
8 0
3 years ago
Greg works for an online games development company. He is not a net freak, but occasionally he visits online literature sites an
sweet-ann [11.9K]

Answer:

i think its A

Explanation:i hope i helped

5 0
3 years ago
Writing anything that comes to mind that may relate to your personal essay is called:
sammy [17]
My life career in computer science
7 0
4 years ago
Read 2 more answers
Other questions:
  • A computer has a memory ________, rather than just a single memory component. The lowest level is some form of ________ storage
    11·1 answer
  • True or false: Your digital footprint is all the information about you online that only you post. Group of answer choices
    12·2 answers
  • With arbitrary code execution, the ________________ launches ("spawns") a command shell from which instructions can then be issu
    11·1 answer
  • T F A stub is a dummy function that is called instead of the actual function it<br><br> represents.
    7·1 answer
  • Given a matrix input_matrix, return a Numpy array that consists of every entry of A that has: an even row index in the range [0,
    9·1 answer
  • Describe how data is transmitted using half-duplex serial data transmission.
    9·1 answer
  • Which statement is true?
    13·2 answers
  • Define operating system?explain the types of operating system on the basis of use.​
    7·1 answer
  • Find out about the different technological solutions available for interconnecting LANs to from larger networks such as wide are
    5·1 answer
  • To read encrypted data, the recipient must decipher it into a readable form. What is the term for this process?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!