Skip to content

Commit dd95b10

Browse files
committed
Added Park application, then moved it to problems folder. Will come back to this file later.
1 parent b1ec529 commit dd95b10

File tree

5 files changed

+185
-2
lines changed

5 files changed

+185
-2
lines changed

Chapter05/Chapter05.iml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,44 @@
77
</content>
88
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
99
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="module-library">
11+
<library>
12+
<CLASSES>
13+
<root url="jar://$APPLICATION_HOME_DIR$/lib/groovy-all-2.2.1.jar!/" />
14+
</CLASSES>
15+
<JAVADOC />
16+
<SOURCES />
17+
</library>
18+
</orderEntry>
19+
<orderEntry type="module-library">
20+
<library>
21+
<CLASSES>
22+
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit.jar!/" />
23+
</CLASSES>
24+
<JAVADOC />
25+
<SOURCES />
26+
</library>
27+
</orderEntry>
28+
<orderEntry type="module-library">
29+
<library name="JUnit4">
30+
<CLASSES>
31+
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
32+
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
33+
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
34+
</CLASSES>
35+
<JAVADOC />
36+
<SOURCES />
37+
</library>
38+
</orderEntry>
39+
<orderEntry type="module-library">
40+
<library>
41+
<CLASSES>
42+
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/testng.jar!/" />
43+
</CLASSES>
44+
<JAVADOC />
45+
<SOURCES />
46+
</library>
47+
</orderEntry>
1048
</component>
1149
</module>
1250

Problems/src/Invoices/Invoice.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package Invoices;
2+
import java.util.Date;
3+
/**
4+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
5+
* On: Jul at: 10:06 PM.
6+
* Project: Java Programming
7+
* Package: Invoices
8+
* File: Invoice
9+
*/
10+
public class Invoice
11+
{
12+
private int invoiceNumber;
13+
private double balanceDue;
14+
private int month;
15+
private int day;
16+
private int year;
17+
public Invoice(int invoice, double balance, int mth, int d, int yr)
18+
{
19+
balanceDue = balance;
20+
if (invoice < 1000)
21+
{
22+
invoice = 0;
23+
}
24+
else
25+
{
26+
invoiceNumber = invoice;
27+
}
28+
if (mth < 1 || mth > 12)
29+
{
30+
mth = 0;
31+
}
32+
else
33+
{
34+
month = mth;
35+
}
36+
if (d < 1 || d > 31)
37+
{
38+
d = 0;
39+
}
40+
else
41+
{
42+
day = d;
43+
}
44+
if (yr < 2011 || yr > 2017)
45+
{
46+
yr = 0;
47+
}
48+
else
49+
{
50+
year = yr;
51+
}
52+
}
53+
public void displayInvoice()
54+
{
55+
System.out.println("Invoice Number: " + invoiceNumber);
56+
System.out.println("Due Date: " + month + "-" + day + "-" + year);
57+
System.out.println("Balance Due: " + balanceDue);
58+
}
59+
}
60+

Problems/src/Invoices/Invoice2.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package Invoices;
2+
/**
3+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
4+
* On: Jul at: 10:06 PM.
5+
* Project: Java Programming
6+
* Package: Invoices
7+
* File: Invoice
8+
*/
9+
public class Invoice2
10+
{
11+
private int invoiceNumber;
12+
private double balanceDue;
13+
private int month;
14+
private int day;
15+
private int year;
16+
public Invoice2(int invoice, double balance, int mth, int d, int yr)
17+
{
18+
balanceDue = balance;
19+
if (invoice < 1000)
20+
{
21+
invoice = 0;
22+
}
23+
else
24+
{
25+
invoiceNumber = invoice;
26+
}
27+
if (mth < 1 || mth > 12)
28+
{
29+
mth = 0;
30+
}
31+
else
32+
{
33+
month = mth;
34+
}
35+
if (d < 1 || d > 31)
36+
{
37+
d = 0;
38+
}
39+
else
40+
{
41+
day = d;
42+
}
43+
if (yr < 2011 || yr > 2017)
44+
{
45+
yr = 0;
46+
}
47+
else
48+
{
49+
year = yr;
50+
}
51+
}
52+
public void displayInvoice()
53+
{
54+
System.out.println("Invoice Number: " + invoiceNumber);
55+
System.out.println("Due Date: " + month + "-" + day + "-" + year);
56+
System.out.println("Balance Due: " + balanceDue);
57+
}
58+
}
59+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Invoices;
2+
/**
3+
* Created by Kimberly Henry <kimberly.henry@outlook.com>
4+
* On: Jul at: 10:36 PM.
5+
* Project: Java Programming
6+
* Package: Invoices
7+
* File: TestInvoice
8+
* Write an application containing a main() method that declares several
9+
* Invoice objects, proving that all the statements in the constructor
10+
* operate as specified. Save the file as TestInvoice.java.
11+
*/
12+
public class TestInvoice
13+
{
14+
public static void main(String[] args)
15+
{
16+
Invoice lessThan = new Invoice(999, 0, 0, 0, 2010);
17+
Invoice moreThan = new Invoice(1001, 56.00, 13, 32, 2018);
18+
Invoice correct = new Invoice(1234, 185.00, 3, 12, 2014);
19+
lessThan.displayInvoice();
20+
System.out.println();
21+
moreThan.displayInvoice();
22+
System.out.println();
23+
correct.displayInvoice();
24+
}
25+
}

Problems/src/Park/TestPark.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
*/
2828
public class TestPark
2929
{
30-
//TODO and fields, constructors, and methods;
3130
public static void main(String[] args)
3231
{
33-
//TODO add methods;
32+
Park test001 = new Park();
33+
test001.isHasPicnic();
34+
test001.isHasPlayground();
3435
}
3536
}

0 commit comments

Comments
 (0)