I have the to classes VacationCostCalculator and a main:
public class Program {
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Not enough input arguments to run this program");
} else {
String transportMethod = args[0];
String distance = args[1];
VacationCostCalculator calculator = new VacationCostCalculator(Double.parseDouble(distance));
double result = calculator.costOfVacation(transportMethod);
System.out.println(result);
}
}
}
package com.itminds.vacationcost;
public class VacationCostCalculator {
private double distanceToDestination;
public VacationCostCalculator(double distance) {
distanceToDestination = distance;
}
public double costOfVacation(String transportMethod) {
switch (transportMethod) {
case "Car":
return distanceToDestination * 1;
case "Plane":
return distanceToDestination * 2;
default:
throw new UnsupportedOperationException();
}
}
public double getDistanceToDestination() {
return distanceToDestination;
}
public void setDistanceToDestination(double distanceToDestination) {
this.distanceToDestination = distanceToDestination;
}
}
My task is to use the right design patterns to finish this application, but I have never learned what the values in the parameter in main is for. I cant find a decent doc that exlplains it well. What do i have to do to make objects of the arguments bigger??? I dont even know what to ask for properly here.. How to run a sample test on this?? is it only through CMD terminal using Javac commands or can i test this by creating other classes that runs this????? i am currently using intellij