My getter wants the method it's getting to have a static method but if I do that it will break my code is there any way around this?. Language Java.
This is the line in my test class that wants to get the method in my vending class.
System.out.println("Total Sales for both machines today $"+ VendingMachine.getTotalsSales());
This is my getter method that takes the array I created from the string provided in the test class that put the items into an array. I want to be able to keep this array that I have created while also getting the total sales.
public double getTotalsSales() {
totalSales += availableItems[this.selectItem].price;
return totalSales;
}
Is there any way I can keep my array and with also being able to grab the total sales from the tester class?