I have set my constructor like this:
public class VendingMachine {
private double currentBalance;
private double itemPrice;
private double totalCollected;
public VendingMachine(double itemCost) {
currentBalance = 0;
totalCollected = 0;
itemPrice = itemCost;
}
...
}
My question is what is the difference from setting up my constructor like above by taking in an argument of a double itemCost
.
What is the difference as opposed to making it:
this.itemPrice = itemCost;