Question: TaskGenerator.java: Implements TaskGeneratorInterface.java and contains the new Task generation, the farmers energy storage, and the probability of passing-out or dying while completing a task. TaskGenerator.java
TaskGenerator.java: Implements TaskGeneratorInterface.java and contains the new Task generation, the farmers energy storage, and the probability of passing-out or dying while completing a task. TaskGenerator.java randomly generates Tasks at the current hour with a priority of 0, with the generations decided by the given probability. There should be multiple overloaded constructors, to allow for the creation of a TaskGenerator with a probability and optional random seed. Note that in order to pass the tests, the TaskGenerator will need specific code in the toString method specified in the interface. You can copy the code from
everything needed here===============>
public class TaskGenerator implements TaskGeneratorInterface {
@Override
public Task getNewTask(int hourCreated, TaskInterface.TaskType taskType, String taskDescription) {
// TODO Auto-generated method stub
return null;
}
@Override
public void decrementEnergyStorage(TaskInterface.TaskType taskType) {
// TODO Auto-generated method stub
}
@Override
public void resetCurrentEnergyStorage() {
// TODO Auto-generated method stub
}
@Override
public int getCurrentEnergyStorage() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setCurrentEnergyStorage(int newEnergyNum) {
// TODO Auto-generated method stub
}
@Override
public boolean generateTask() {
// TODO Auto-generated method stub
return false;
}
@Override
public int getUnlucky(Task task, double unluckyProbability) {
// TODO Auto-generated method stub
return 0;
}
@Override
public String toString(Task task, Task.TaskType taskType) {
if(taskType == Task.TaskType.MINING) {
return " Mining " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")";
}
if(taskType == Task.TaskType.FISHING) {
return " Fishing " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")" ;
}
if(taskType == Task.TaskType.FARM_MAINTENANCE) {
return " Farm Maintenance " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")";
}
if(taskType == Task.TaskType.FORAGING) {
return " Foraging " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")" ;
}
if(taskType == Task.TaskType.FEEDING) {
return " Feeding " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")";
}
if(taskType == Task.TaskType.SOCIALIZING) {
return " Socializing " + task.getDescription() + " at " + currentEnergyStorage + " energy points (Priority:" + task.getPriority() +")";
}
else { return "nothing to see here..."; }
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
