Java 在窗口中使用其他类的信息需要帮助吗?
我需要从这两个类中获取信息,以便在窗口上显示xc im。 我每次尝试不同的东西都会遇到问题,所以我又回到了这个话题。 我15岁了,最近我又开始编程了,我只是说这些东西,因为它不允许我发布tadaJava 在窗口中使用其他类的信息需要帮助吗?,java,Java,我需要从这两个类中获取信息,以便在窗口上显示xc im。 我每次尝试不同的东西都会遇到问题,所以我又回到了这个话题。 我15岁了,最近我又开始编程了,我只是说这些东西,因为它不允许我发布tada import java.awt.Component; import javax.swing.JLabel; import javax.swing.JFrame; public class CoffeeHomework{ public static void main(String[] args)
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");
} }
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"; }
}
}
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.
} }