// Gillian Andrews // MSTU4031 // Group 2 Final Project -- Practice Element import java.awt.*; import javax.swing.*; import java.awt.event.*; /** THIS NEEDS: -Something that makes it so you can't go on to the next screen if you haven't filled in the text -The final variables need to go into the main method */ // the overall class public class Practice1 extends JApplet { // the constructor -- currently temporarily showing panels for demo public Practice1() { PracticePanel = new ImagePanel(); NorthPanel = new JPanel(); SouthPanel = new JPanel(); degreesField = new JTextField(200); // degrees hypothesis appearField = new JTextField(200); // appearance hypothesis nextButton = new JButton("Next"); submitButton = new JButton("That's my answer!"); compareButton = new JButton("Compare my answers"); northPrompts = new JLabel(""); southPrompts1 = new JLabel(""); southPrompts2 = new JLabel(""); SouthPanel.add(nextButton); getContentPane().add(NorthPanel, BorderLayout.NORTH); getContentPane().add(PracticePanel, BorderLayout.CENTER); getContentPane().add(SouthPanel, BorderLayout.SOUTH); } class HypothesisListener implements ActionListener /** takes in input from text box and slots it to Strings based on what "turn" (subIteration) we're on */ { public void actionPerformed(ActionEvent event) { if (subIteration == 2) { String degreesHypo = degreesField.getText(); } if (subIteration == 3) { String appearHypo = appearField.getText(); } if (subIteration == 4) { String degreesObserve = degreesField.getText(); String appearObserve = appearField.getText(); } else { // nuffin! } } } class CornerDragListener /** listens for mouse drag so that corners can be moved */ { } // public void TriangleArcRotate() /** Considering not using this one because it may be tough. Recalculates the coordinates of one of the corners of a triangle so that it can be fit into the other corners. */ // { // } public void PlaceComponents() /** Places the buttons and text fields on the South bar after it has been cleared*/ { if (subIteration == 1) { //Temporarily using rectangle as test case northPrompts.setText("This is a" + RECT_ANGLE + RECT_DESCRIP); SouthPanel.add(nextButton); } if (subIteration == 2) { northPrompts.setText("What do its angles add up to?"); southPrompts1.setText("I think they add up to"); SouthPanel.add(degreesField); southPrompts2.setText("degrees."); } if (subIteration == 3) { northPrompts.setText("If you tore the corners off this shape and put their points together, what shape would it look like?"); southPrompts1.setText("I think it would look like"); SouthPanel.add(appearField); } if (subIteration == 4) { } if (subIteration == 5) { } else { // nuffin! } } class RefreshButtonListener implements ActionListener /** refreshes the panels (equivalent of going to the "next screen") */ { public void actionPerformed(ActionEvent event) { } } class ImagePanel extends JPanel /** where the shapes are being drawn */ { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; } } // there are five subIterations for each superIteration private int subIteration; /** there are at least two superIterations. There are definitely two superIterations per shape (quadrilateral or triangle) */ private int superIteration; private Rectangle squareRect; private Rectangle rectRect; private Polygon mutilated; // private Line2D.Double divider; // needs four private Arc2Ds? private JTextField degreesField; private JTextField appearField; /** these three buttons really don't do anything different but I'm not taking the time to make a MakeButton method right now */ private JButton nextButton; private JButton submitButton; private JButton compareButton; private JLabel northPrompts; private JLabel southPrompts1; private JLabel southPrompts2; private ImagePanel PracticePanel; private JPanel NorthPanel; private JPanel SouthPanel; private RefreshButtonListener refreshListener; private HypothesisListener degreesListener; private HypothesisListener appearListener; private CornerDragListener dragListener; // I think all these final variables actually belong in the main class private static final String ISOSCELES_TRIANGLE = "n isosceles triangle. "; private static final String ISO_DESCRIP = "All its angles and sides are the same."; private static final String RIGHT_TRIANGLE = " right triangle. "; private static final String RIGHT_DESCRIP = "Right triangles have one 90 degree angle and two sides of equal length."; private static final String RECT_ANGLE = " rectangle. "; private static final String RECT_DESCRIP = "Rectangles are quadrilaterals. This means they have four sides. Rectangles also have four right angles."; private static final String SQU_ARE = " square. "; private static final String SQUARE_DESCRIP = "A square is a quadrilateral as well, and it also has four right angles. Unlike most rectangles, all four of its sides are the same length."; }