
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Using Java - write a new class called Rack, to store an ArrayList of Tiles, to sort them using the Selection Sort
Code:
class Main
{
publicstaticvoid main(String[] args)
{
Rack craigTiles = new Rack();
craigTiles.addTile(new Tile('H', 4));
craigTiles.addTile(new Tile('E', 1));
craigTiles.addTile(new Tile('L', 1));
craigTiles.addTile(new Tile('L', 1));
craigTiles.addTile(new Tile('O', 1));
craigTiles.addTile(new Tile('Z', 10));
craigTiles.addTile(new Tile('Y', 4));
craigTiles.sortHighToLow();
System.out.println("Craig's rack of tiles, in order from most valuable to least:");
System.out.println(craigTiles);
Rack bettoTiles = new Rack();
bettoTiles.addTile(new Tile('E', 1));
bettoTiles.addTile(new Tile('A', 1));
bettoTiles.addTile(new Tile('S', 1));
bettoTiles.addTile(new Tile('D', 2));
bettoTiles.addTile(new Tile('W', 4));
bettoTiles.addTile(new Tile('T', 1));
bettoTiles.addTile(new Tile('N', 1));
bettoTiles.sortHighToLow();
System.out.println("Betto's rack of tiles, in order from most valuable to least:");
System.out.println(bettoTiles);
}
}
/*
Sample Outputs:
Craig's rack of tiles, in order from most valuable to least:
Z H Y L O E L
Betto's rack of tiles, in order from most valuable to least:
W D S A E T N
*/
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Similar questions
- JAVAarrow_forwardFor any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20,30, 1 #include 2 3 int main(void) { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; 4 6 7 8 scanf("%d", &keysList[0]); scanf ("%d", &keysList[1]); scanf("%d", &keysList[2]); scanf("%d", &keysList[3]); 10 11 12 13 scanf ("%d", &itemsList[0]); scanf ("%d", &itemsList[1]); scanf("%d", &itemsList[2]); scanf ("%d", &itemsList[3]); 14 15 16 17 18 19 /* Your code goes here */ 20 21 printf("\n"); 22 23 return 0; 24 }arrow_forwardJavaarrow_forward
- This is needed in Javaarrow_forwardJava - Sort an Arrayarrow_forward/** * TODO: file header */ import java.util.*; public class BSTManual { /** * TODO * @author TODO * @since TODO */ // No style for this file. public static ArrayList<String> insertElements() { ArrayList<String> answer_pr1 = new ArrayList<>(11); /* * make sure you add your answers in the following format: * * answer_pr1.add("1"); --> level 1 (root level) of the output BST * answer_pr1.add("2, X"); --> level 2 of the output BST * answer_pr1.add("3, X, X, X"); --> level 3 of the output BST * * the above example is the same as the second pictoral example on your * worksheet */ //TODO: add strings that represent the BST after insertion. return answer_pr1; } public static ArrayList<String> deleteElements() { ArrayList<String> answer_pr2 = new ArrayList<>(11); /* * Please refer to the example in insertElements() if you lose track * of how to properly enter your answers */ //TODO: add strings that represent the…arrow_forward
- Java Programming language Please help me with this questionarrow_forwardJAVA Program(*MUST WORK IN HYPERGRADE*) Homework #1. Chapter 7. PC# 2. Payroll Class (page 488-489) Write a Payroll class that uses the following arrays as fields: * employeeId. An array of seven integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 * hours. An array of seven integers to hold the number of hours worked by each employee * payRate. An array of seven doubles to hold each employee’s hourly pay rate * wages. An array of seven doubles to hold each employee’s gross wages The class should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose identification number is stored in element 0 of the employeeId array. That same employee’s pay rate should be stored in element 0 of the payRate array. The class should have a method that accepts an…arrow_forward#Steps: Create a Main class. Declare an ArrayList in the main() method and store the given values in it. Create an array called output of the size of the ArrayList. Iterate through for-loop to get each element from the array List and load it into the array using the get() method of the list. Print the array to see the loaded elements. import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { List<String> nameList = new ArrayList<String>(); nameList.add("Robert"); nameList.add("Samson"); nameList.add("Alex"); nameList.add("William"); System.out.println("Elements of List: " + nameList); // Create an array of the same size as nameList Hint: use size() method // Fetch the elements from the nameList and insert into newly created array // Hint: Use get() method to fetch the elements from…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY