Based on the information in the screenshots, please answer the following question below. The language used is Java and please provide the code for it with the explanation. Create a testing class named “PlanTest”. Under this class, there needs to be another static method besides the main method: You will need to create a static method named “prerequisiteGenerator” under “PlanTest”, which return a random 2D array containing prerequisite pairs (e.g., {{1, 3}, {2, 3}, {4, 2}}). The value range of a random integer is [0, 10] (inclusive). This method will accept an integer parameter, which specifies the length of the returned array: int[][] pre = prerequisiteGenerator(3); // possibly {{1, 3}, {2, 3}, {4, 2}} Under the main method, you will need to use prerequisiteGenerator to generate random prerequisite pair lists, and perform tests on plan method at least three examples by printing proper messages. Given 4 courses and prerequisites as [[1,0], [2,0], [3,1]] It is possible to take all the given courses. A possible schedule is 0, 1, 2, 3. Please give the below code. import java.util.*; public class PlanTest { public static void main(String[] args) { } // this method generates a list of prerequisits as a 2D array private int[][] prerequisiteGenerator(int size) { // remove these two lines int[][] result = new int[1][1]; return result; } }
Based on the information in the screenshots, please answer the following question below. The language used is Java and please provide the code for it with the explanation.
Create a testing class named “PlanTest”. Under this class, there needs to be another static method besides the main method:
- You will need to create a static method named “prerequisiteGenerator” under “PlanTest”, which return a random 2D array containing prerequisite pairs (e.g., {{1, 3}, {2, 3}, {4, 2}}). The value range of a random integer is [0, 10] (inclusive). This method will accept an integer parameter, which specifies the length of the returned array:
int[][] pre = prerequisiteGenerator(3); // possibly {{1, 3}, {2, 3}, {4, 2}}
- Under the main method, you will need to use prerequisiteGenerator to generate random prerequisite pair lists, and perform tests on plan method at least three examples by printing proper messages.
Given 4 courses and prerequisites as [[1,0], [2,0], [3,1]]
It is possible to take all the given courses.
A possible schedule is 0, 1, 2, 3.
Please give the below code.
import java.util.*;
public class PlanTest {
public static void main(String[] args) {
}
// this method generates a list of prerequisits as a 2D array
private int[][] prerequisiteGenerator(int size) {
// remove these two lines
int[][] result = new int[1][1];
return result;
}
}
Step by step
Solved in 3 steps with 1 images