Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Exam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
67160191
Exam
Commits
f0a244d7
Commit
f0a244d7
authored
3 months ago
by
First nakub
Browse files
Options
Downloads
Patches
Plain Diff
"Calculator"
parent
a162ecc5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Test.java
+2
-4
2 additions, 4 deletions
src/Test.java
with
2 additions
and
4 deletions
src/Test.java
+
2
−
4
View file @
f0a244d7
...
...
@@ -53,7 +53,6 @@ public class Test implements WindowListener, ActionListener {
bDot
=
new
Button
(
"."
);
bEqual
=
new
Button
(
"="
);
// Add listeners to buttons
b1
.
addActionListener
(
this
);
b2
.
addActionListener
(
this
);
b3
.
addActionListener
(
this
);
...
...
@@ -71,7 +70,6 @@ public class Test implements WindowListener, ActionListener {
bDiv
.
addActionListener
(
this
);
bEqual
.
addActionListener
(
this
);
// Add buttons to panel
p2
.
add
(
b7
);
p2
.
add
(
b8
);
p2
.
add
(
b9
);
...
...
@@ -125,7 +123,7 @@ public class Test implements WindowListener, ActionListener {
public
void
actionPerformed
(
ActionEvent
e
)
{
String
cmd
=
e
.
getActionCommand
();
// If a number or decimal is pressed
if
(
cmd
.
equals
(
"0"
)
||
cmd
.
equals
(
"1"
)
||
cmd
.
equals
(
"2"
)
||
cmd
.
equals
(
"3"
)
||
cmd
.
equals
(
"4"
)
||
cmd
.
equals
(
"5"
)
||
cmd
.
equals
(
"6"
)
||
cmd
.
equals
(
"7"
)
||
cmd
.
equals
(
"8"
)
||
cmd
.
equals
(
"9"
)
||
cmd
.
equals
(
"."
))
{
...
...
@@ -138,7 +136,7 @@ public class Test implements WindowListener, ActionListener {
operator
=
cmd
;
numStr
=
""
;
}
// If equal sign is pressed
else
if
(
cmd
.
equals
(
"="
))
{
operand2
=
numStr
;
num1
=
Double
.
parseDouble
(
operand1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment