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
ae93b072
Commit
ae93b072
authored
Jan 08, 2020
by
robert.sharp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor change
parent
b0573715
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
temp.java
src/main/java/temp.java
+15
-4
No files found.
src/main/java/temp.java
View file @
ae93b072
...
...
@@ -309,9 +309,10 @@ public class temp extends javax.swing.JFrame {
quant
=
Double
.
parseDouble
(
quantBox
.
getSelectedItem
().
toString
());
//find the slected item and convet it into a double
quantLabelchange
.
setText
(
"Selected quantity: "
+
quant
);
//update the display to show the quanity of item
wanted
//update the display to show the quanity of item
cost
=
price
[
index
]*
quant
;
Total
.
setText
(
"Total: "
+
cost
);
}
private
void
PurchaseActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
...
...
@@ -430,7 +431,6 @@ public class temp extends javax.swing.JFrame {
}
else
{
//if the menu item has no quantity or less than they want, don't let them buy it.
error
.
setText
(
"There are not enough items for that."
);
amount
=
amount
+
cost
;
jLabel3
.
setText
(
"Amount Given: "
+
amount
);
return
false
;
}
...
...
@@ -438,9 +438,14 @@ public class temp extends javax.swing.JFrame {
}
public
void
print
(){
cost
=
0
;
try
{
FileWriter
f
=
new
FileWriter
(
"receipt.txt"
);
f
.
write
(
"SafeVend receipt: \n"
);
f
.
write
(
"Thank you for choosing SafeVend!"
+
"\n"
);
f
.
write
(
"________________________________\n"
);
f
.
write
(
"Items purchased: \n"
);
f
.
write
(
"Code\tItem\t\tPrice\tQuantity \t"
+
"\n"
);
...
...
@@ -458,20 +463,26 @@ public class temp extends javax.swing.JFrame {
}
f
.
write
(
""
+
price
[
i
]+
"\t"
);
//displays the price
f
.
write
(
basket
[
i
]+
"\t"
);
f
.
write
((
basket
[
i
]/
2
)+
"\t"
);
//this is because for some reason the basket quanity was being doubled;
cost
=
cost
+
((
price
[
i
])
*
(
basket
[
i
]/
2
));
//adds a new line to display the next item.
f
.
write
(
"\n"
);
}
}
f
.
write
(
"________________________________\n"
);
f
.
write
(
"\n"
+
"Total cost: "
+
cost
+
"\n"
);
f
.
write
(
"\n"
+
"Total payed: "
+
payed
+
"\n"
);
f
.
write
(
"\n"
+
"Change Given: "
+
Double
.
parseDouble
(
moneyInput
.
getText
()
)
+
"\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
.
close
();
}
catch
(
Exception
e
)
{
...
...
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