#Java Coffee Machine Program

12 messages · Page 1 of 1 (latest)

valid sphinx
#

Not sure why, but my program has quite a few red underlines. Not really sure what I did wrong at this point. Should be easy to fix.

public class CoffeeMain {

public static void main(String[] args) {
    CoffeeMain lS = new CoffeeMain("Latte", "Small", "Water, Milk, Sugar", 2); 
    CoffeeMain lB = new CoffeeMain("Latte", "Big", "Water, Milk, Sugar", 4); 
    CoffeeMain cS = new CoffeeMain("Cappucino", "Small", "Water, Milk, Sugar", 3); 
    CoffeeMain cB = new CoffeeMain("Cappucino", "Big", "Water, Milk, Sugar", 6); 
    CoffeeMain eS = new CoffeeMain("Espresso", "Small", "Water, Milk, Sugar", 4); 
    CoffeeMain eB = new CoffeeMain("Espresso", "Big", "Water, Milk, Sugar", 8); 
    
    lS.usersOrder();
}

}


public class CoffeeOther {

String type;
String size;
String ingredients;
int cost;

public CoffeeOther(String t, String s, String i, int c) {
    this.type = t;
    this.size = s;
    this.ingredients = i;
    this.cost = c;
    
}
void usersOrder() {
    System.out.println("You ordered a " + this.size + " " + this.type + " that costs " + this.cost + " and is made of " + this.ingredients);
}

}

autumn pathBOT
#

This post has been reserved for your question.

Hey @valid sphinx! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

valid sphinx
#

screenshots, if they help.

autumn pathBOT
#
Not sure why, but my program has quite a few red underlines. Not really sure what I did wrong at this point. Should be easy to fix.


public class CoffeeMain {
	
	public static void main(String[] args) {
		CoffeeMain lS = new CoffeeMain("Latte", "Small", "Water, Milk, Sugar", 2); 
		CoffeeMain lB = new CoffeeMain("Latte", "Big", "Water, Milk, Sugar", 4); 
		CoffeeMain cS = new CoffeeMain("Cappucino", "Small", "Water, Milk, Sugar", 3); 
		CoffeeMain cB = new CoffeeMain("Cappucino", "Big", "Water, Milk, Sugar", 6); 
		CoffeeMain eS = new CoffeeMain("Espresso", "Small", "Water, Milk, Sugar", 4); 
		CoffeeMain eB = new CoffeeMain("Espresso", "Big", "Water, Milk, Sugar", 8); 
		
		lS.usersOrder();
	}
	
	
}

-------------------------------------------------------------------------------------------------------------


public class CoffeeOther {
	
	String type;
	String size;
	String ingredients;
	int cost;
	
	public CoffeeOther(String t, String s, String i, int c) {
		this.type = t;
		this.size = s;
		this.ingredients = i;
		this.cost = c;
		
	}
	void usersOrder() {
		System.out.println("You ordered a " + this.size + " " + this.type + " that costs " + this.cost + " and is made of " + this.ingredients);
	}
	
	
	
}
bold linden
#

what does the error say ?

valid sphinx
#

The declaration of new objects should have been New CoffeeOther, not New CoffeeMain

#

Switched all the CoffeeMains to CoffeeOther and it fixed the problem

bold linden
valid sphinx
#

Yep

autumn pathBOT
# autumn path

Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.