Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part Two: Event Handling Instructions Create a new branch from your existing main branch. Give the branch a name that will be recognizable to you
Part Two: Event Handling Instructions
Create a new branch from your existing main branch. Give the branch a name that will be recognizable to you later as events works.
On your newly created branch, implement an event table that handles click events for every button. Do not use bind for this lab.
Button Functionality
When the following buttons are pressed, their button label or corresponding symbol will be added to the text control.
Numbers
Binary Operation Buttons
Decimal Button
Negative Button
Unary Operation Buttons Sin Cos, Tan
Clear Button
The clear button should fully clear the text box and the backspace button should remove the last character in the textbox. The backspace button should repeat this behavior until there's nothing left in the textbox.
BackspaceDelete Button
The backspace button should delete the last character in the text control. Repeatedly pressing the backspace button should continue deleting each character until the text control is empty. The program should not crash if the text control is empty.
Equals Button
The button will attempt to calculate whatever string is contained within the text control, clear it and display the result in the text control.
The program should not crash if the text box is empty or if the text control contains an invalid expression.
Calculations
Implement simple calculations mod At the very least, you should be able to perform each of these math operations on two numbers. should work, but does not need to just yet
Review string parsing concepts to tokenize the string in your textbox into separate tokens. If is in your textbox, pressing should parse and as floating point values and as the operation to occur between those two values. There are several ways to accomplish this. Also note that unary negation should be supported and expression such as for example, should evaluate to
wxWidgets comes with it's own wxStringTokenizer that you may use. You also have the option to make your own tokenizer, but this is not recommended for this assignment.
Simple unary operations Sin Cos, Tan should also be implemented. Pressing Sin and should add "Sin to your textbox, and pressing should result in the Sine of
Unary operations should still be added as a string to your text box. Do not immediately evaluate numbers in your textbox. The equals button should still be pressed in order to evaluate any expressions, including unary operations.
Try to find a way to implement the event table without having everything hardcoded. You should be able to handle all events in a single event function a portion of this is shown in Lecture
Exception Handling
Basic exception handling is required. It's your responsibility to ensure that any thrown exceptions are handled gracefully and do not crash the program. Any program you write should be thoroughly tested to the best of your abilities. Common exceptions include but may not be limited to:
Pressing backspace on an empty text box
Dividing and modding by
Evaluating an empty textbox
Evaluating an invalid expression etc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started