Write a Java console application that reads plow and route data from files and s
ID: 641092 • Letter: W
Question
Write a Java console application that reads plow and route data from files and stores them in objects. The program will then read an order file to dispatch the plows on the various routes. The program will have the following three classes: Plow.java, Route.java, HW4_1.java
The files included are PlowData.txt which contains:
RouteData.txt which should contain:
OrderData.txt which should include:
You have been hired by the Genesee County Road Commission to write an application to dispatch snow plows on the county roads. Write a Java console application that reads plow and route data from files and stores them in objects. The program will then read an order file to dispatch the plows on the various routes. The program will have the following three classes:
Plow.java
This class represents one snow plow and should include:
? Instance variables
int plowID
String driver
String status
Explanation / Answer
Comment if you have any doubts
Please increase the points and comment for the final HW4_1 class.
//Plow class
public class Plow
{
private int plowID,totalHours,hoursLeft,plowCount;
private String driver,status;
public Plow()
{
this.plowID=-1;
this.driver="(not set)";
this.status="(not set)";
this.totalHours=0;
this.hoursLeft=0;
this.plowCount+=1;
}
public Plow(int plowID,String driver)
{
this.plowID=plowID;
this.driver=driver;
this.status="active";
this.totalHours=0;
this.hoursLeft=0;
this.plowCount+=1;
}
public int getPlowID() {
return plowID;
}
public int getTotalHours() {
return totalHours;
}
public int getHoursLeft() {
return hoursLeft;
}
public int getPlowCount() {
return plowCount;
}
public String getDriver() {
return driver;
}
public String getStatus() {
return status;
}
public void setPlowID(int plowID) {
this.plowID = plowID;
}
public void setTotalHours(int totalHours) {
this.totalHours = totalHours;
}
public void setHoursLeft(int hoursLeft) {
this.hoursLeft = hoursLeft;
}
public void setPlowCount(int plowCount) {
this.plowCount = plowCount;
}
public void setDriver(String driver) {
this.driver = driver;
}
public void setStatus(String status) {
this.status = status;
}
public void printPlowInfo()
{
System.out.println("PlowID: "+this.plowID+" Driver: "+this.driver+" Status: "+this.status);
System.out.println("Plow Count: "+this.plowCount+" Total Hours: "+this.totalHours+" Hoursleft: "+this.hoursLeft);
}
public boolean equals(Plow newPlow)
{
return this.plowID==newPlow.plowID;
}
public String toString()
{
return "PlowID: "+this.plowID+" Driver: "+this.driver+" Status: "+this.status+" Plow Count: "+this.plowCount+" Total Hours: "+this.totalHours+" Hoursleft: "+this.hoursLeft;
}
}
//##################################################################################################
//Route class
public class Route
{
private int routeID,routeHours;
private static int routeCount;
public Route()
{
this.routeID=-1;
this.routeHours=0;
Route.routeCount+=1;
}
public Route(int routeID,int routeHours)
{
this.routeID=routeID;
this.routeHours=routeHours;
Route.routeCount+=1;
}
public int getRouteID() {
return routeID;
}
public int getRouteHours() {
return routeHours;
}
public static int getRouteCount() {
return routeCount;
}
public void setRouteID(int routeID) {
this.routeID = routeID;
}
public void setRouteHours(int routeHours) {
this.routeHours = routeHours;
}
public static void setRouteCount(int routeCount) {
Route.routeCount = routeCount;
}
public void printRouteInfo()
{
System.out.println("Route ID: "+this.routeID+" Route Hours: "+this.routeHours+" Route Count: "+Route.routeCount);
}
public boolean equals(Route newRoute)
{
return this.routeID==newRoute.routeID;
}
public String toString()
{
return "Route ID: "+this.routeID+" Route Hours: "+this.routeHours+" Route Count: "+Route.routeCount;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.