Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is my code for an upcoming assignment. I need help constructing a UML diagram off of the information below.: Node.java OperatorNode.java OperandNode.java ExpressionTree.java MyGUI.java

Below is my code for an upcoming assignment. I need help constructing a UML diagram off of the information below.:

Node.java

image text in transcribed

OperatorNode.java

image text in transcribed

OperandNode.java

image text in transcribed

ExpressionTree.java

image text in transcribed

MyGUI.java

image text in transcribed

// define the class Node public class Node //declare the variables protected String data; protected Node leftNode; protected Node rightNode; //getter and setter methods of the instance variables public String getData() return data; public void setData (String data) this.data = data; public Node getLeftNode () return leftNode; public void setLeftNode (Node leftNode) this.leftNode = leftNode; public Node getRightNode () return rightNode; public void setRightNode (Node rightNode) this.rightNode = rightNode; public String toString() return "(" + this.leftNode + " " + data + " " + this.rightNode + " )"; //define the class OperatorNode which extends Node public class OperatorNode extends Node // constructor // sets the variables public OperatorNode (String operator) this.data = operator; this.leftNode = null; this.rightNode = null; //definition of the method toString() @Override public String toString() return "(" + this.leftNode + " " + data + " " + this.rightNode + ")"; //define the class OperandNode which extends Node public class OperandNode extends Node //constructor // sets the variables public OperandNode (String operand) this.data = operand; this.leftNode = null; this.rightNode = null; //definition of the method toString() @Override public String toString() return data + ""; import java.io. Printwriter; import java.util.Stack; import java.util.StringTokenizer; import javax.swing.JOption Pane; public class ExpressionTree //create a Stack of type Type private Stack stack = new Stack(); //create a Node variable private Node added; //definition of the method checkForOperator() public static boolean checkForOperator (String str) // check if the str is "+" , "-", "*" ,"/" if( str.equals("+") || str.equals("-") 11 str.equals("*") || str.equals("/")) return true; return false; // definition of the method checkForInteger() // check for integer and returns boolean value public static boolean check ForInteger (String str) try Integer.parseInt(str); return true; } catch (Number FormatException nfe) return false; // definition of the method postfixExpressionDilimeter() // it takes postfixExpression and returns the array of string public String[] postfixExpressionDilimeter (String postfixExpression) String expression; expression = postfixExpression; // split the expression and assign into array String[] arry = expression.split("\\s+"); String splitExpression = ""; //declare the header files import java.awt.BorderLayout; import java.awt. Dimension; import java.awt.event. ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import javax.swing. JButton; import javax.swing.JFrame; import javax.swing. JLabel; import javax.swing.JPanel; import javax.swing.JTextField; //Define the class MyGUI public class MyGUI extends JFrame implements ActionListener //create an object for the class ExpressionTree () ExpressionTree tree = new ExpressionTree(); //definition of the method main() public static void main(String[] args) throws IOException // call the constructor of the MyGUI class new MyGUI(); // constructor public MyGUI () throws IOException //create a Label JLabel promptLabel = new JLabel("Enter Postfix Expression"); //create a Panel JPanel upper Panel = new JPanel(); // create a TextField final JTextField postfixTextField = new JTextField(); //set the dimensions of the postfixTextField postfixTextField.setPreferredSize (new Dimension (250, 25)); // add the promptLabel in the upper Panel upper Panel.add (promptLabel, BorderLayout. EAST) ; // add the postfixTextField in the upper Panel upper Panel.add (postfixTextField, BorderLayout. EAST); // create a JLabel infixLabel JLabel infixLabel = new JLabel("Infix Expression"); // create Panel bottomPanel JPanel bottomPanel = new JPanel(); // create a TextField final JTextField resultTextField = new JTextField()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago