classyclass.java :
package work1;
public class classyclass {
public static void main(String[] args) {
int num;
num = 0;
num++;
System.out.println(" blah blah blah " + num);
Coffee latte = new Coffee();
Coffee capuccino = new Coffee();
latte.price = 5;
capuccino.price = 11;
latte.beverage();
capuccino.beverage();
}
}
Coffee.java :
package work1;
public class Coffee {
int price;
String coffeeType;
void beverage() {
if (coffeeType == "latte" )
{
System.out.println("The price of latte is " + latte.price );
}
else if(coffeeType == "capuccino")
{
System.out.println("The price of a cappuccino is " + capuccino.price);
}
}
}
As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help