Question: 1a) Generating the next point in the range Write a method getNextPoint that takes as input three doubles parameters. The first parameter is a double
1a) Generating the next point in the range Write a method getNextPoint that takes as input three doubles parameters. The first parameter is a double which represents the height of the previous point in the mountain range. The second parameter is a double which is the possible steepness between adjacent points. Finally, the last parameter is a double, which is the maximum height of any point in the mountain range This method takes the previous point in the mountain range, and creates a height for the new point The difference between the previous height and the new point is based on a random change controlled by the steepness parameter For example, let the previous point be 10.5, and the steepness parameter be 3.0. The new point must be 10.5 plus a random number in the range of -3.0 to 3.0. Therefore, the new point will be in the range of 7.5 to 18.5. This means that the larger the steepness parameter is, the larger the difference in height between one point in the mountain range and the next. Note that in the two example mountains provided, the steepness of the first example is much higher than that of the second example, and the mountains are much steeper We also need to make sure that the height of the new point is not too large or too smal. If the new point is above the maximum height (which is the third parameter to the method), then the new point's height must be set to be equal to the maximum height. Similarly, if the new point's height is below zero, then the new point's height must be set to zero. To summarize, the new point is based on the old point, plus a change based on the steepness. The new point's height cannot be above the maximum height, or below zero
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
