subject

Please help! The ExperimentalFarm class represents crops grown on an experimental farm. An experimental farm is a rectangular tract of land that is divided into a grid of equal-sized plots. Each plot in the grid contains one type of crop. The crop yield of each plot is measured in bushels per acre.

A farm plot is represented by the Plot class. A partial definition of the Plot class is shown below.

public class Plot

{

private String cropType;

private int cropYield;

public Plot(String crop, int yield)

{

/* implementation not shown */

}

public String getCropType()

{

return cropType;

}

public int getCropYield()

{

return cropYield;

}

}

The grid of equal-sized plots is represented by a two-dimensional array of Plot objects named farmPlots, declared in the ExperimentalFarm class. A partial definition of the ExperimentalFarm class is shown below.

public class ExperimentalFarm

{

private Plot[][] farmPlots;

public ExperimentalFarm(Plot[][] p)

{

/* implementation not shown */

}

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

{

/* to be implemented in part (a) */

}

/** Returns true if all plots in a given column in the two-dimensional array farmPlots

* contain the same type of crop, or false otherwise, as described in part (b).

*/

public boolean sameCrop(int col)

{

/* to be implemented in part (b) */

}

}

(a) Write the getHighestYield method, which returns the Plot object with the highest yield among the plots in farmPlots with the crop type specified by the parameter c. If more than one plot has the highest yield, any of these plots may be returned. If no plot exists containing the specified type of crop, the method returns null.

Assume that the ExperimentalFarm object f has been created such that its farmPlots array contains the following cropType and cropYield values.

The figure presents a two-dimensional array of Plot objects with 3 columns and 4 rows. The columns are labeled from 0 to 2, and the rows are labeled from 0 to 3. Each plot is labeled with a crop name and crop yield as follows. Row 0. Column 0, "Corn" 20. Column 1, "Corn" 30. Column 2, "Peas" 10. Row 1. Column 0, "Peas" 30. Column 1, "Corn" 40. Column 2, "Corn" 62. Row 2. Column 0, "Wheat" 10. Column 1, "Corn" 50. Column 2, "Rice" 30. Row 3. Column 0, "Corn" 55, Column 1, "Corn" 30. Column 2, "Peas" 30.
The following are some examples of the behavior of the getHighestYield method.

Method Call Return Value
f. getHighestYield("corn") ​farmPlots[1][3]
f. getHighestYield("peas") farmPlots[1][0] or farmPlots[3][2]​
f. getHighestYield("bananas") null
Write the getHighestYield method below.

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:30
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 23.06.2019 21:10
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
You know the right answer?
Please help! The ExperimentalFarm class represents crops grown on an experimental farm. An experime...
Questions
question
World Languages, 29.09.2019 23:50
Questions on the website: 13722360