Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VendingMachine_Robert_Sharp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
robert.sharp
VendingMachine_Robert_Sharp
Commits
31614d54
Commit
31614d54
authored
Jan 08, 2020
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated broken variables;
parent
d7539e9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
temp.java
src/main/java/temp.java
+6
-13
No files found.
src/main/java/temp.java
View file @
31614d54
...
@@ -296,7 +296,7 @@ public class temp extends javax.swing.JFrame {
...
@@ -296,7 +296,7 @@ public class temp extends javax.swing.JFrame {
//find the items index
//find the items index
PriceLabel
.
setText
(
"Price: "
+
price
[
index
]);
PriceLabel
.
setText
(
"Price: "
+
price
[
index
]);
//returns it's price.
//returns it's price.
cost
=
price
[
index
]*
quant
;
cost
=
price
[
index
]*
(
quant
*
2
)
;
Total
.
setText
(
"Total: "
+
cost
);
Total
.
setText
(
"Total: "
+
cost
);
}
}
...
@@ -306,11 +306,11 @@ public class temp extends javax.swing.JFrame {
...
@@ -306,11 +306,11 @@ public class temp extends javax.swing.JFrame {
private
void
quantBoxActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
private
void
quantBoxActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
// TODO add your handling code here:
// TODO add your handling code here:
findItem
();
findItem
();
quant
=
Double
.
parseDouble
(
quantBox
.
getSelectedItem
().
toString
());
quant
=
Double
.
parseDouble
(
quantBox
.
getSelectedItem
().
toString
())
/
2
;
//find the slected item and convet it into a double
//find the slected item and convet it into a double
quantLabelchange
.
setText
(
"Selected quantity: "
+
quant
);
quantLabelchange
.
setText
(
"Selected quantity: "
+
(
quant
*
2
)
);
//update the display to show the quanity of item
//update the display to show the quanity of item
cost
=
price
[
index
]*
quant
;
cost
=
price
[
index
]*
(
quant
*
2
)
;
Total
.
setText
(
"Total: "
+
cost
);
Total
.
setText
(
"Total: "
+
cost
);
}
}
...
@@ -463,9 +463,9 @@ public class temp extends javax.swing.JFrame {
...
@@ -463,9 +463,9 @@ public class temp extends javax.swing.JFrame {
}
}
f
.
write
(
""
+
price
[
i
]+
"\t"
);
f
.
write
(
""
+
price
[
i
]+
"\t"
);
//displays the price
//displays the price
f
.
write
((
basket
[
i
]
/
2
)+
"\t"
);
f
.
write
((
basket
[
i
])+
"\t"
);
//this is because for some reason the basket quanity was being doubled;
//this is because for some reason the basket quanity was being doubled;
cost
=
cost
+
((
price
[
i
])
*
(
basket
[
i
]
/
2
));
cost
=
cost
+
((
price
[
i
])
*
(
basket
[
i
]));
//adds a new line to display the next item.
//adds a new line to display the next item.
f
.
write
(
"\n"
);
f
.
write
(
"\n"
);
}
}
...
@@ -475,13 +475,6 @@ public class temp extends javax.swing.JFrame {
...
@@ -475,13 +475,6 @@ public class temp extends javax.swing.JFrame {
f
.
write
(
"\n"
+
"Total payed: "
+
payed
+
"\n"
);
f
.
write
(
"\n"
+
"Total payed: "
+
payed
+
"\n"
);
f
.
write
(
"\n"
+
"Change Given: "
+
(
payed
-
cost
)
+
"\n"
);
f
.
write
(
"\n"
+
"Change Given: "
+
(
payed
-
cost
)
+
"\n"
);
if
(
change
>=
0
){
f
.
write
(
"\n"
+
"valid payment: "
+
true
);
}
else
{
f
.
write
(
"\n"
+
"valid payment: "
+
false
);
f
.
write
(
"\n"
+
"Service Denied."
);
}
f
.
write
(
"\n________________________________"
);
f
.
write
(
"\n________________________________"
);
f
.
close
();
f
.
close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment