subject

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 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

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 06:30, toolazytobehuman
Me and category do i put them in because this is science
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, ratpizza
Which describes careers that have similar education requirements but different qualifications? product safety engineers and materials engineers industrial safety engineers and industrial health engineers quality control systems managers and inspectors industrial safety and health engineers and hand packers
Answers: 3
image
Computers and Technology, 24.06.2019 18:20, mshepherdmiller
Acommon algorithm for converting a decimal number to binary is to repeatedly divide the decimal number by 2 and save the remainder. this division is continued until the result is zero. then, each of the remainders that have been saved are used to construct the binary number. write a recursive java method that implements this algorithm. it will accept a value of int and return a string with the appropriate binary character representation of the decimal number. my code: public class lab16{public string converttobinary(int input){int a; if(input > 0){a = input % 2; return (converttobinary(input / 2) + "" +a); } return ""; } }
Answers: 1
image
Computers and Technology, 25.06.2019 02:30, gabby0148
On the pie chart below, which “slice” represents 30% of the budget?
Answers: 2
You know the right answer?
The grid of equal-sized plots is represented by a two-dimensional array of Plot objects named farmPl...

Questions in other subjects:

Konu
Mathematics, 22.10.2020 04:01