Summer 2019 CS313 Project
Implementation of a GUI to work with Expression Trees.
Reminder: This is a pass/fail assignment. You do not have to do a perfect job to pass the assignment, but you must submit something that compiles and creates a GUI that performs most of the required tasks. The surest way to fail this assignment is to use code written by somebody else or to share code with another student. I will use an automated system that detects similarity between different pieces of code.
The final deadline for this project is Monday 08/12/2019. However there are preliminary milestones that you should try to achieve. You should submit preliminary versions of the project to check that you have achieved them. The deadlines for these milestones are as follows:
• Phase 1: Due 07/25/19: Code to show a Gui screen with required buttons, labels and text fields.
• Phase 2: Due 08/01/19: The Gui should be able to enter and display an expression tree (using standard infix notation).
• Phase 3: Due 08/08/19: The Gui should be able to use prefix and postfix notation to read or write an expression.
• Phase 4: Due 05/14/19: Complete code which will be able to find and display the value represented by any node of the expression tree.
I advise you to try to submit work for the preliminary phases. This is optional, but it is a way for me to give you feedback about whether you are on track with the project. If your project does not complete the first three phases it will not pass.
When you submit any version of your project (preliminary or final) you should submit only one file named ETxxxxxxxx.java where xxxxxxxx is changed to be the 8 digits of your CUNY ID number. For example, if your id number was 31415926 you would submit a file called ET31415926.java.
The main class in this file must be a public class ET31415926 but no other classes that you use can be public (because only one public class is allowed in a file). Although this is not an ideal way to organize code it simplifies my task in grading. I will not accept any other type of submission either for the final version or the earlier milestones. Submit the homework by emailing your one file as an attachment from your own Queens College email account to [email protected] The subject for your email must be: CS313 Project Phase X, where X is the phase corresponding to your file. Late work will not be considered for any phase of the project. Email from addresses outside Queens College will not be accepted.
The gui that you make should offer the features shown here. This screenshot has been made before any expression has been entered. This screenshot shows what you must achieve during Phase 1.
The top line of the gui is used to display the current expression under con- sideration. A user can also type a new expression on this line in order to enter an expression tree. The next screenshot shows how the gui should respond when the user enters a simple expression (1 + 2 ∗ 3) ∗ (5 ∗ 3 − 2). This screenshot shows what should be achieved during Phase 2 — this is the most demanding phase of the project.
The goal of phase 3 is to make the radio buttons Infix notation, Prefix notation and Postfix notation control the notation used to display the expression under consideration on the top line. If Postfix notation is selected, the content of the gui should change as follows. (While this button is selected, new input should also be read in postfix notation.)
In phase 4, you should allow the user to click on nodes shown on the gui display. Clicking a node will highlight it and make the value of the subtree at the node appear in the Value box on the bottom line of the gui.
For example the value of the root is the value of the whole expression, in 3
this case 91 whereas the value of the node storing − is the value of the subtree rooted there which is 13.
Although the first phase of this project just involves Gui code, later phases will require work with an Expression tree data structure. You will need methods to convert an input String to tree data, to display tree data as an output String, and to evaluate an expression tree (or a node of the tree). You will also need methods to determine the depth and width coordinates for any node of the tree so that it can be displayed properly. The depth method should be familiar. You can apply one of the standard traversals to do most of the work for the width method. You should make sure that nodes in your display expand to the correct size to display their content.
I will compile and run your program on a Unix machine similar to venus. You should make sure that if you move your file ETxxxxxxxx.java to venus you can compile it with the command:
If you use unusual packages and libraries this might cause compilation prob- lems. It is important to resolve these problems before submitting the project. Do not wait until the final stage to do this.
Some common issues that could prevent Phase 1 work from compiling on venus are:
1. An initial package line (inserted by eclipse) was left as the first line of the file. This should be removed because it refers to a particular eclipse set up and directory structure that will not be present on venus or other machines.
2. The file contains no public class.
3. The public class contains no main method.
4. The public class has a different name from the file.
Figure 1: An example showing wider nodes.
Also make sure to set a default close operation so that your program ends when the GUI is closed.
Your code must be your own. However, you are free to make use of any books and online information so long as you do not copy existing code. If you have made use of any such resources, or discussed the project with other people, you must begin your code with a comment explaining what resources you have used and who you discussed the project with.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:dmxyzl003