As far as I can tell, I'm either out of my mind, or this is fishy.
My program displays text on the screen. ✅
The addPrice method does NOT display text on the screen. ✅
The applePrice variable is static and initialized to zero. ✅
addPrice is only being called twice. ✅
The cost increases the cost of apples by the passed-in value. ✅
CodeGym says I'm failing. ✅
Please help. <3
package en.codegym.task.jdk13.task04.task0402;
/*
Price of apples
*/
public class Solution {
public static void main(String[] args) {
Apple apple = new Apple();
apple.addPrice(50);
Apple apple2 = new Apple();
apple2.addPrice(100);
System.out.println("Apple price " + Apple.applePrice);
}
public static class Apple {
public static int applePrice = 0;
public void addPrice(int applePrice) {
applePrice = Apple.applePrice + applePrice;
}
}
}