Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Adam Gerber
/
labJava
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
08b37074
authored
Nov 09, 2015
by
Adam Gerber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
again programming to interfaces
parent
496eae85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
src/lec07/glab/vend/Driver.java
src/lec07/glab/vend/VendMachine.java
src/lec07/glab/vend/Driver.java
View file @
08b37074
package
lec07
.
glab
.
vend
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
/**
...
...
@@ -18,7 +19,7 @@ public class Driver {
VendMachine
vndMachine
=
new
VendMachine
();
Array
List
<
Product
>
prdProducts
=
new
ArrayList
<>();
List
<
Product
>
prdProducts
=
new
ArrayList
<>();
prdProducts
.
add
(
new
Product
(
"Heath"
,
0.75
));
prdProducts
.
add
(
new
Product
(
"PayDay"
,
0.75
));
prdProducts
.
add
(
new
Product
(
"Reces"
,
0.75
));
...
...
@@ -48,7 +49,7 @@ public class Driver {
System
.
out
.
println
(
vndMachine
.
showSelection
());
strSelect
=
makeSelection
();
if
(
strSelect
.
equalsIgnoreCase
(
"AABBCC"
)){
Array
List
<
Coin
>
conCashOuts
=
vndMachine
.
cashOut
();
List
<
Coin
>
conCashOuts
=
vndMachine
.
cashOut
();
System
.
out
.
println
(
"Jackpot!"
);
for
(
Coin
conCashOut
:
conCashOuts
)
{
System
.
out
.
println
(
conCashOut
);
...
...
@@ -60,7 +61,7 @@ public class Driver {
System
.
out
.
println
(
"Thank you and Enjoy: "
+
prdProduct
);
else
{
System
.
out
.
print
(
"You inserted "
+
vndMachine
.
howMuchInserted
()
+
" : Insufficient coins or out of stock"
);
Array
List
<
Coin
>
conReturns
=
vndMachine
.
returnCoins
();
List
<
Coin
>
conReturns
=
vndMachine
.
returnCoins
();
System
.
out
.
println
(
", here is your money back: "
);
for
(
Coin
conReturn
:
conReturns
)
{
System
.
out
.
println
(
conReturn
);
...
...
src/lec07/glab/vend/VendMachine.java
View file @
08b37074
...
...
@@ -72,7 +72,7 @@ public class VendMachine {
}
public
void
stockMe
(
Array
List
<
Product
>
prdProducts
){
public
void
stockMe
(
List
<
Product
>
prdProducts
){
//for each row
//for each col
...
...
@@ -145,7 +145,7 @@ public class VendMachine {
}
public
void
insertCoins
(
Array
List
<
Coin
>
conPassed
){
public
void
insertCoins
(
List
<
Coin
>
conPassed
){
for
(
Coin
con
:
conPassed
)
{
mPurchaseMoneys
.
add
(
con
);
}
...
...
@@ -154,7 +154,7 @@ public class VendMachine {
}
public
void
insertCoins
(
String
strCoinValue
){
Array
List
<
Coin
>
conCoins
=
new
ArrayList
<>();
List
<
Coin
>
conCoins
=
new
ArrayList
<>();
String
[]
strCoins
=
strCoinValue
.
split
(
" "
);
for
(
String
strCoin
:
strCoins
)
{
...
...
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