import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JFrame;
public class CoffeeHomework{
public static void main(String[] args) {
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(1280, 720);
window.setVisible(true);
window.setTitle("Coffee Program");
} }
我需要从这两个类中获取信息以显示在xc im cumped的窗口上。 我每次尝试不同的东西时都会遇到问题,所以我回到了这里。 我十五岁,我刚刚再次接受编程,是的我只是说所有这些东西kuz它不会让我发布tada。
class CoffeeReturn{
public static double CoffeeCode(double code){
double price = 0.0;
if(code == 1101101){
price = 25.50;
}
return price;
}
public String CoffeeDesc(double code){
String desc = "Black Coffee";
if(code == 1101101){
return desc;
}
else{ return "invalid code"; }
}
}
答案 0 :(得分:0)
public static void main(String[] args) {
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(1280, 720);
window.setVisible(true);
window.setTitle("Coffee Program");
CoffeeReturn yourCoffeeReturn = new CoffeeReturn();
yourCoffeeReturn.CoffeeDesc(123456);
CoffeeReturn.CoffeeCode(123456); // this is statis so no need to instantiate a new CoffeeReturn.
} }