Java Programming
COP2210_Project3-FALL2020/build.xml
Builds, tests, and runs the project COP2210_Project3-FALL2020.COP2210_Project3-FALL2020/build/built-jar.properties
#Fri, 04 Dec 2020 14:39:35 -0500 C\:\\Users\\user\\Documents\\NetBeansProjects\\COP2210_Project3-FALL2020=
COP2210_Project3-FALL2020/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
COP2210_Project3-FALL2020/nbproject/build-impl.xml
Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agentCOP2210_Project3-FALL2020/nbproject/genfiles.properties
build.xml.data.CRC32=0e47a5f4 build.xml.script.CRC32=c8cc2a7e [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=0e47a5f4 nbproject/build-impl.xml.script.CRC32=37b10357 nbproject/[email protected]
COP2210_Project3-FALL2020/nbproject/private/private.properties
compile.on.save=true user.properties.file=C:\\Users\\user\\AppData\\Roaming\\NetBeans\\12.0\\build.properties
COP2210_Project3-FALL2020/nbproject/private/private.xml
file:/C:/Users/user/Documents/NetBeansProjects/COP2210_Project3-FALL2020/src/client/Person.java file:/C:/Users/user/Documents/NetBeansProjects/COP2210_Project3-FALL2020/src/app/Controller.java file:/C:/Users/user/Documents/NetBeansProjects/COP2210_Project3-FALL2020/src/payment/CreditCard.java file:/C:/Users/user/Documents/NetBeansProjects/COP2210_Project3-FALL2020/src/goods/Item.javaCOP2210_Project3-FALL2020/nbproject/project.properties
annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.modulepath=\ ${run.modulepath} debug.test.classpath=\ ${run.test.classpath} debug.test.modulepath=\ ${run.test.modulepath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/COP2210_Project3-FALL2020.jar dist.javadoc.dir=${dist.dir}/javadoc dist.jlink.dir=${dist.dir}/jlink dist.jlink.output=${dist.jlink.dir}/COP2210_Project3-FALL2020 excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.modulepath= javac.processormodulepath= javac.processorpath=\ ${javac.classpath} javac.source=14 javac.target=14 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.modulepath=\ ${javac.modulepath} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.html5=false javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= # The jlink additional root modules to resolve jlink.additionalmodules= # The jlink additional command line parameters jlink.additionalparam= jlink.launcher=true jlink.launcher.name=COP2210_Project3-FALL2020 main.class=app.Controller manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.modulepath=\ ${javac.modulepath} run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} run.test.modulepath=\ ${javac.test.modulepath} source.encoding=UTF-8 src.dir=src test.src.dir=test
COP2210_Project3-FALL2020/nbproject/project.xml
org.netbeans.modules.java.j2seproject COP2210_Project3-FALL2020COP2210_Project3-FALL2020/src/app/Controller.java
COP2210_Project3-FALL2020/src/app/Controller.java
package
app
;
//imports here
// YOUR CODE HERE
import
java
.
util
.
Random
;
import
client
.
Person
;
import
goods
.
Item
;
import
payment
.
CreditCard
;
public
class
Controller
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
// create a person variable named john with following info:
// FirstName: John
// LastName: Doe
// Street Address: 1100 Brickell Ave
// Suite Address: Apt 102
// City: Miami
// State: Florida
// YOUR CODE HERE
Person
john
=
new
Person
(
"John"
,
"Doe"
,
"1100 Brickell Ave"
,
"Apt 102"
,
" Miami"
,
"Florida"
);
// create a Credit Card variable named masterCard with the following info:
// cardHolder: the person that you create above
// Type: MasterCard
// Credit Limit: 2500.00
// YOUR CODE HERE
CreditCard
masterCard
=
new
CreditCard
(
john
,
"MasterCard"
,
2500.00
);
// create a Credit Card variable named ax with the following info:
// cardHolder: the person that you create above
// Type: American Express
// Credit Limit: 5000.00
// YOUR CODE HERE
CreditCard
ax
=
new
CreditCard
(
john
,
"American Express"
,
5000.00
);
//adding the masterCard to john
john
.
getCreditCards
().
add
(
masterCard
);
// add the American Express to the person john
john
.
getCreditCards
().
add
(
ax
);
// creating and Item variable named cafeMocha with the following info:
Item
cafeMocha
=
new
Item
(
"Food"
,
"Cafe Mocha"
,
4.77
);
// creating and Item variable named gucciSlipper with the following info:
// Cataory: Clothing
// Name: Gucci Princetown
// Price: 2650.00
// YOUR CODE HERE
Item
gucciSlipper
=
new
Item
(
"Clothing"
,
"Gucci Princetown"
,
2650.00
);
// creating and Item variable named coke with the following info:
// Cataory: Food
// Name: Coke
// Price: 1.99
// YOUR CODE HERE
Item
coke
=
new
Item
(
"Food"
,
"Coke"
,
1.99
);
// creating and Item variable named airlinesTicket with the following info:
// Cataory: Travel
// Name: MIA-SFO
// Price: 823.26
// YOUR CODE HERE
Item
airlinesTicket
=
new
Item
(
"Travel"
,
"MIA-SFO"
,
823.26
);
// john is buying cafeMocha using his MasterCard credit card
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
cafeMocha
);
// john is buying gucciSlipper using his MasterCard credit card
// hint this may run into credit limit issues
// YOUR CODE HERE
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
gucciSlipper
);
// john is buying gucciSlipper using his American Express credit card
// YOUR CODE HERE
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
gucciSlipper
);
// john is running a transaction Report on his MasterCard
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
transactionsReport
();
// john is running a transaction Report on his American Express
// YOUR CODE HERE
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
transactionsReport
();
Random
generator
=
new
Random
();
// buying 7 cafeMocha using different credit cards
for
(
int
i
=
1
;
i
<=
7
;
i
++
){
// DO NOT MESS WITH THE SLEEP CODE
// sleep for a random time upto 1 seconds
Thread
.
sleep
(
generator
.
nextInt
(
1001
));
// buy cafeMocha on MasterCard if the cafeMocha is a multiple 3
// else buy it on the AX card
// example
// i = 1 -> Buy it on the AX
// i = 2 -> Buy it on the AX
// i = 3 -> Buy it on the MasterCard
// i = 4 -> Buy it on the AX
// ...
// hint use if else statement
// YOUR CODE HERE
if
(
i
%
3
==
0
)
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
cafeMocha
);
}
else
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
cafeMocha
);
}
}
//end for
// buying 5 airlinesTicket using different credit cards
for
(
int
i
=
1
;
i
<=
5
;
i
++
){
// DO NOT MESS WITH THE SLEEP CODE
// sleep for a random time upto 1 seconds
Thread
.
sleep
(
generator
.
nextInt
(
1001
));
// buy airlinesTicket on MasterCard if i is even
// else buy it on the AX card
// hint use if else statement
// YOUR CODE HERE
if
(
i
%
2
==
0
)
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
airlinesTicket
);
}
else
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
airlinesTicket
);
}
}
//end for
// buying 10 cokes using different credit cards
for
(
int
i
=
1
;
i
<=
10
;
i
++
)
{
// sleep for a random time upto 1 seconds
Thread
.
sleep
(
generator
.
nextInt
(
1001
));
// this is use to be randomly select a credit card
int
randomSelectCard
=
generator
.
nextInt
(
2
);
// if randomSelectCard is 0 use the MasterCard
// if this is the case print out "randomSelectCard: MasterCard"
// if randomSelectCard is 1 use the American Express
// if this is the case print out "randomSelectCard: MasterCard"
// hint use if else statement
// YOUR CODE HERE
if
(
randomSelectCard
==
0
)
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
coke
);
}
else
{
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
makeCharge
(
coke
);
}
}
//end for
// john is running a transaction Report on his masterCard
// YOUR CODE HERE
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
transactionsReport
();
// john is running a transaction Report on his American Express
// YOUR CODE HERE
((
CreditCard
)
john
.
getCreditCards
().
get
(
0
)).
transactionsReport
();
// john is running displayInfo method
// YOUR CODE HERE
transactionsReport
().
displayInfo
();
}
//end main
}
//end class
COP2210_Project3-FALL2020/src/client/Person.java
COP2210_Project3-FALL2020/src/client/Person.java
package
client
;
import
java
.
util
.
ArrayList
;
import
payment
.
CreditCard
;
public
class
Person
{
//---------------------------------------------------------------------------
// Instance Variable
//---------------------------------------------------------------------------
// check the UML diagram to see which instance variable you need
private
String
firstName
;
private
String
lastName
;
private
String
streetAddress
;
private
String
suiteAddress
;
private
String
cityAddress
;
private
String
stateAddress
;
private
ArrayList
creditCards
;
//---------------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------------
public
Person
(
String
firstName
,
String
lastName
,
String
streetAddress
,
String
suiteAddress
,
String
cityAddress
,
String
stateAddress
)
{
// assign the input values to the instance variables
// YOUR CODE HERE
this
.
firstName
=
firstName
;
this
.
lastName
=
lastName
;
this
.
streetAddress
=
streetAddress
;
this
.
suiteAddress
=
suiteAddress
;
this
.
cityAddress
=
cityAddress
;
this
.
stateAddress
=
stateAddress
;
creditCards
=
new
ArrayList
<>
();
}
//end constructor
//---------------------------------------------------------------------------
// Setter and Getters
//---------------------------------------------------------------------------
public
String
getFirstName
()
{
return
firstName
;
}
public
void
setFirstName
(
String
firstName
)
{
this
.
firstName
=
firstName
;
}
public
String
getLastName
()
{
return
lastName
;
}
public
void
setLastName
(
String
lastName
)
{
this
.
lastName
=
lastName
;
}
public
String
getStreetAddress
()
{
return
streetAddress
;
}
public
void
setStreetAddress
(
String
streetAddress
)
{
this
.
streetAddress
=
streetAddress
;
}
public
String
getSuiteAddress
()
{
return
suiteAddress
;
}
public
void
setSuiteAddress
(
String
suiteAddress
)
{
this
.
suiteAddress
=
suiteAddress
;
}
// write the code for the needed setter and getters
// check the UML Diagram
// YOUR CODE HERE
public
String
getCityAddress
()
{
return
cityAddress
;
}
public
void
setCityAddress
(
String
cityAddress
)
{
this
.
cityAddress
=
cityAddress
;
}
public
String
getStateAddress
()
{
return
stateAddress
;
}
public
void
setStateAddress
(
String
stateAddress
)
{
this
.
stateAddress
=
stateAddress
;
}
public
ArrayList
getCreditCards
()
{
return
creditCards
;
}
public
void
setCreditCards
(
ArrayList
creditCards
)
{
this
.
creditCards
=
creditCards
;
}
//---------------------------------------------------------------------------
// Utility Methods
//---------------------------------------------------------------------------
public
void
displayInfo
(){
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"============================================================================"
);
System
.
out
.
println
(
"Display Information"
);
System
.
out
.
println
(
"============================================================================"
);
System
.
out
.
printf
(
"%-20s %s %s \n"
,
"Name:"
,
firstName
,
lastName
);
System
.
out
.
printf
(
"%-20s %-20s \n"
,
"Address:"
,
streetAddress
);
// write the code needed for the output to match the project doc output
// hint look at the code above to have the correct format
// YOUR CODE HERE
System
.
out
.
printf
(
"%-20s %-20s \n"
,
"Suite:"
,
suiteAddress
);
System
.
out
.
printf
(
"%-20s %-20s \n"
,
"City:"
,
cityAddress
);
System
.
out
.
printf
(
"%-20s %-20s \n"
,
"State:"
,
stateAddress
);
System
.
out
.
println
(
"------------------"
);
System
.
out
.
println
(
"Credit Card Info"
);
System
.
out
.
println
(
"------------------"
);
for
(
int
i
=
0
;
i
<
creditCards
.
size
();
i
++
){
String
cardName
=
((
CreditCard
)
creditCards
.
get
(
i
)).
getType
();
// get the creditCards credit limit
// hint look at the code for cardName above
double
creditLimit
=
masterCard
.
getCreditLimit
();
// YOUR CODE HERE
// get the creditCards current balance
// hint look at the code for cardName above
double
currentBalance
=
masterCard
.
getCurrentBalance
();
// YOUR CODE HERE
System
.
out
.
printf
(
"%-20s %-20s \n"
,
"CreditCard:"
,
cardName
);
System
.
out
.
printf
(
"%-20s %-20.2f \n"
,
"Credit Limit:"
,
creditLimit
);
System
.
out
.
printf
(
"%-20s %-20.2f \n"
,
"Current Balance:"
,
currentBalance
);
System
.
out
.
println
(
""
);
}
}
//----------------------------------------------------
}
}
//end class
COP2210_Project3-FALL2020/src/goods/Item.java
COP2210_Project3-FALL2020/src/goods/Item.java
package
goods
;
public
class
Item
{
private
String
category
;
private
String
name
;
private
double
price
;
public
Item
(
String
category
,
String
name
,
double
price
)
{
this
.
category
=
category
;
this
.
name
=
name
;
this
.
price
=
price
;
}
public
String
getCategory
()
{
return
category
;
}
public
String
getName
()
{
return
name
;
}
public
double
getPrice
()
{
return
price
;
}
public
void
setPrice
(
double
price
,
String
personal
)
{
this
.
price
=
price
;
}
public
void
displayInfo
(){
}
}
//end class
COP2210_Project3-FALL2020/src/payment/CreditCard.java
COP2210_Project3-FALL2020/src/payment/CreditCard.java
package
payment
;
import
client
.
Person
;
import
goods
.
Item
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
Date
;
public
class
CreditCard
{
private
Person
cardHolder
;
private
String
type
;
private
String
cardNumber
;
private
double
creditLimit
;
private
double
currentBalance
;
private
double
nextPaymentAmount
;
private
ArrayList
<
Item
>
transactions
;
private
ArrayList
<
Date
>
transactionsTimeStamps
;
//---------------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------------
public
CreditCard
(
Person
cardHolder
,
String
type
,
double
creditLimit
)
{
// assign the input to the instance variables
// YOUR CODE HERE
this
.
cardHolder
=
cardHolder
;
this
.
type
=
type
;
this
.
creditLimit
=
creditLimit
;
transactions
=
new
ArrayList
<
Item
>
();
transactionsTimeStamps
=
new
ArrayList
<
Date
>
();
}
//---------------------------------------------------------------------------
// Setters and Getters
//---------------------------------------------------------------------------
public
Person
getCardHolder
()
{
return
cardHolder
;
}
public
String
getType
()
{
return
type
;
}
public
String
getCardNumber
()
{
return
cardNumber
;
}
public
double
getCreditLimit
()
{
return
creditLimit
;
}
public
void
setCreditLimit
(
double
creditLimit
,
String
personal
)
{
this
.
creditLimit
=
creditLimit
;
}
public
double
getCurrentBalance
()
{
return
currentBalance
;
}
public
double
getNextPaymentAmount
()
{
return
nextPaymentAmount
;
}
//---------------------------------------------------------------------------
// Utility Methods
//---------------------------------------------------------------------------
public
void
makeCharge
(
Item
item
){
if
(
item
.
getPrice
()
<=
(
creditLimit
-
currentBalance
))
{
// YOUR CODE HERE){
transactions
.
add
(
item
);
Date
date
=
new
Date
();
transactionsTimeStamps
.
add
(
date
);
currentBalance
+=
item
.
getPrice
();
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"Charging: "
+
item
.
getName
());
System
.
out
.
println
(
"Transaction completed successfully"
);
System
.
out
.
println
(
"Please remove your "
+
type
);
System
.
out
.
println
(
""
);
}
else
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"Charging: "
+
item
.
getName
());
System
.
out
.
println
(
"Transaction was not successful"
);
System
.
out
.
println
(
"Credit Limit Issue"
);
System
.
out
.
println
(
"Please remove your "
+
type
);
System
.
out
.
println
(
""
);
}
}
//end makeCharge
public
void
transactionsReport
()
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"============================================================================"
);
System
.
out
.
println
(
type
+
" Transaction Report"
);
System
.
out
.
println
(
"============================================================================"
);
System
.
out
.
printf
(
"%-20s $%-10.2f\n"
,
"Credit Limit:"
,
creditLimit
);
// you need to print out the Available Credit
// YOUR CODE HERE
System
.
out
.
printf
(
"%-20s $%-10.2f\n"
,
"Available Credit:"
,
creditLimit
-
currentBalance
);
System
.
out
.
printf
(
"%-20s $%-10.2f\n"
,
"Current Balance:"
,
currentBalance
);
System
.
out
.
println
(
"------------------------------------------------------------------------"
);
double
totalCharges
=
0.0
;
for
(
int
i
=
0
;
i
<
transactions
.
size
();
i
++
)
{
Item
item
=
transactions
.
get
(
i
);
Date
date
=
transactionsTimeStamps
.
get
(
i
);
System
.
out
.
printf
(
"%-20s %-10s $%-10.2f %-10s\n"
,
item
.
getName
(),
item
.
getCategory
(),
item
.
getPrice
(),
date
.
toString
());
totalCharges
+=
item
.
getPrice
();
}
//end for
System
.
out
.
println
(
"------------------------------------------------------------------------"
);
System
.
out
.
printf
(
"%-15s Total Charges: $%-10.2f\n"
,
""
,
totalCharges
);
}
//end transactionsReport
}
//end class