Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在窗口中使用其他类的信息需要帮助吗?_Java - Fatal编程技术网

Java 在窗口中使用其他类的信息需要帮助吗?

Java 在窗口中使用其他类的信息需要帮助吗?,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)

我需要从这两个类中获取信息,以便在窗口上显示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) {

    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.

}  }