私の宿題には、GUI の作成が含まれます。宿題をやってくれる人を探しているわけではありませんが、宿題をよりよく理解する手助けをしたいだけです。次のクラスをコーディングします。クラスをテストするには、個別のクラスと個別のドライバー プログラムが必要なので、作業を分割します。必要に応じて MATH クラスを使用します。float または double プリミティブ データ型も必ず使用してください。追加の生徒には、デフォルトのコンストラクター (デフォルト値を double の場合は 2.0f または 2.0 に設定) と、float または double のいずれかのデータを受け入れるオーバーロードされたメソッドが必要です。
さらに、学生はクラスへのインターフェイスとしてグラフィカル ユーザー インターフェイス プログラミング技術を使用する必要があります。生徒は、ラベル、ボタン、ラジオ ボタン、メニュー、およびスライダーを使用できます。
正方形クラス (周囲と面積)
主に私が助けを必要としているもの:
コンストラクタはどこに行くべきですか?このコードでオーバーロードされるように実装するにはどうすればよいですか? このコードでメソッドをオーバーロードするにはどうすればよいですか?
    import javax.swing.*;
    import java.awt.event.*; // Needed for ActionListener Interface
    /**
     * The BugayTestSquare 3 class displays a JFrame that lets the user enter in the
     * sides of the of a square. When the calculate button is pressed, a dialog box
     * will be displayed with the area and perimeter shown. 
     */
    public class FirstGUI extends JFrame
    {
        /*
         * Acording to good class design princples, the fields are private.
         */
        private JPanel panel;
        private JLabel messageLabel, messageLabel2;
        private JTextField lengthTextField;
        private JButton calcButton;
        private final int WINDOW_WIDTH = 310;
        private final int WINDOW_HEIGHT = 150;
        /**
         * Constructor
     */
    public FirstGUI()
    {
        // Set the window title
        setTitle("Area and Perimiter Calculator");
        // Set the size of the window.
        setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        // Specify what happens when the close button is clicked.
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // Build the panel and add it to the frame.
        buildPanel();
        // Add the panel to the frames content pane.
        add(panel);
        //diplay the window.
        setVisible(true);
    }
    /** The buildPanel method adds a label, 
     * text field, and a button to a panel.
     **/
    private void buildPanel()
    {
        // Create a label to display instructions.
        messageLabel = new JLabel("Please enter in the length " +
                                  "of the square.");
        messageLabel2 = new JLabel("Please enter in the width " +
                                 "of the square.");
        // Create a text field 10 characters wide.
        lengthTextField = new JTextField(10);
        //Create a button with the caption "Calculate."
        calcButton = new JButton("Calculate");
        // Add an action listener to the button.
        calcButton.addActionListener(new FirstGUI.CalcButtonListener());
        //Create a JPanel object and let the
        // panel field reference it.
        panel =new JPanel();
        // Add the label, text field, and button.
        // components to the panel.
        panel.add(messageLabel);
        panel.add(messageLabel2);
        panel.add(lengthTextField);
        panel.add(calcButton);
    }
    /**
     * CalcButtonListener is an action listener 
     * class for the Calculate button.
     */
    private class CalcButtonListener implements ActionListener
    {
        /**
         * The actionPerformed method executes when the user
         * clicks on the Calculate Button.
         * @param e The Event Object.
         */
        public void actionPerformed(ActionEvent e)
        {
            String input; // To hold the user's input
            double area; // The area
            double perimeter; // the perimter
            // Get the text entered by the user into the
            // text field
            input = lengthTextField.getText();
            //Perform Calculations
            area = Double.parseDouble(input)*2; 
            perimeter = Double.parseDouble(input)*4;
            //Display the result.
            JOptionPane.showMessageDialog(null, "Your area is " +area +
                "\nYour perimter is " + perimeter);
        }
    }
}