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
monitta
3 years ago
3

Write the mostValuableNeighbor method, which compares the item in row r and column c to the items to its left and to its right.

The method determines which of the three items has the greatest value and returns its name. If more than one of the values have a value that is greatest, then any of their names can be returned. If the item has no item to its left, it is compared only to the item to its right. If the item has no item to its right, it is compared only to the item to its left.
Computers and Technology
1 answer:
OLga [1]3 years ago
6 0

Answer:

Explanation:

The following method is written in Java, using the Item class and ItemGrid class found online we can use this method to grab the 2-dimensional array and compare the three neighbors in the same row. It saves the position of the neighbor with the greatest value in the variable greatest and then uses that position to call the getName() method from the object in that position to get the name of that Neighbor and returns the name.

public String mostValuableNeighbor(ItemGrid grid, int r, int c) {

       int greatest = grid[r][c];

      if (grid[r][c+1].getValue() > greatest.getValue()) {

          greatest = grid[r][c+1];

      }

       if (grid[r][c-1].getValue() > greatest.getValue()) {

           greatest = grid[r][c-1];

       }

       

      return greatest.getName();

   }

You might be interested in
Processor speeds are in bytes.<br><br> True<br> or<br> False
Aneli [31]

Answer:

true

Explanation:

Mainly true, but partly false. There are two bits in a computer that supply speed: The processor (measured in hertz eg. 2Ghz Processor) and RAM (bits and bytes eg 2GB of RAM). The processor is more to do with the speed programs run and load at, and RAM let's you use lots of memory intensive programs at the same time, although this also comes down to the processor and vice versa. Hope I helped :)

5 0
3 years ago
Read 2 more answers
What is the part of the browser window that displays the content of the web page such as pictures and text called?
iragen [17]
The frame is a part of the web page or browser window
5 0
3 years ago
What does D'Artagnan discover about Milady? d. That she has the mark of a criminal, the fleur- c. That she is secretly working f
Setler79 [48]
The answers is b .....
6 0
3 years ago
Read 2 more answers
Importance of good safe design
KengaRu [80]

Answer:

Safe design incorporates ergonomics principles as well as good work design. Good work design helps ensure workplace hazards and risks are eliminated or minimised so all workers remain healthy and safe at work.

Explanation:

Good work design, or safety in design, considers hazards and risks as early as possible in the planning and design process. It aims to eliminate or minimise the possibility of workplace injury or illness throughout the life of the product or process. ... products. layout and configuration

3 0
3 years ago
Read 2 more answers
The ________ program displays graphics and loading screens during the boot process.
Minchanka [31]
Booting would be complete if the normal, runtime environment has been achieved. A boot loader is a program that loads operating system for the computer after the completion of power on tests. The boot manager is a program that displays graphics and loading screens during the boot process.
3 0
3 years ago
Other questions:
  • Andrea wants to to install a new internet connection . she eants to use the fastest one she can find . what are the maximum spee
    14·1 answer
  • Create a security management policy that addresses the management and the separation of duties throughout the seven domains of a
    6·1 answer
  • IN JAVA Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin ty
    15·1 answer
  • A technician has been asked to troubleshoot a simple network problem that seems to be caused by software. Which troubleshooting
    7·1 answer
  • By including ______
    15·2 answers
  • Prepare a algorithm visualization for the Tower of Hanoi when 4 disks are to be moved from spindle #1 to spindle #3.
    12·1 answer
  • I have been trying for 2 days to make an account, but it says registration cannot be completed at this time. It is extremely ann
    12·2 answers
  • Which precaution should you take while working on a computer
    9·1 answer
  • How does PowerPoint know which objects to group? The objects are aligned side by side. The objects are placed in one part of the
    11·2 answers
  • Lists are indexed by an ________. a. float b. integer c. string d. All of the above​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!