Question: Can someone help me create a test class for this JAVA code import java.util.*; public class DoneVehicles { private List manualList = new ArrayList ();

Can someone help me create a test class for this JAVA code

import java.util.*; public class DoneVehicles { private List manualList = new ArrayList(); private List autoList = new ArrayList(); private int maxManualWait = 0; private int maxAutoWait = 0; private double avgManualWait = 0; private double avgAutoWait = 0; //Constructor public DoneVehicles(){} //access lists directly public List getManualList() { return manualList; } public List getAutomaticList() { return autoList; } //list info methods public int getMaxManualWait(){ int maxWaitTime = 0, manualWait=0;//this is well above any possible waiting value for (ManualVehicle vehicle : manualList) { manualWait = vehicle.getWaitingTime(); if(manualWait>maxWaitTime) { maxWaitTime = manualWait; } } return maxWaitTime; } public double getAverageManualWait(){ double avgWaitTime = 0; for (ManualVehicle vehicle : manualList) { avgWaitTime += (double)(vehicle.getWaitingTime())/(manualList.size()-1); //prevents overflow via += method } return avgWaitTime; } public int getMaxAutomaticWait(){ int maxWaitTime = 0, autoWait=0;//this is well above any possible waiting value for (AutomaticVehicle vehicle : autoList) { autoWait = vehicle.getWaitingTime(); if(autoWait>maxWaitTime) { maxWaitTime = autoWait; } } return maxWaitTime; } public double getAverageAutomaticWait(){ double totalWaitTime = 0, avgWaitTime = 0; for (AutomaticVehicle vehicle : autoList) { avgWaitTime += (double)(vehicle.getWaitingTime())/(autoList.size()-1); //prevents overflow } return avgWaitTime; } public int manualCount(){ return manualList.size()-1; } public int automaticCount(){ return autoList.size()-1; } //add to list methods by type public void addManual(ManualVehicle vehicle){ manualList.add(vehicle); vehicle.passTollBooth(); } public void addAutomatic(AutomaticVehicle vehicle){ autoList.add(vehicle); vehicle.passTollBooth(); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!