Skip to content

Commit a4a4d64

Browse files
author
java-tester-x
committed
redesign project structure
1 parent e207e72 commit a4a4d64

15 files changed

Lines changed: 112 additions & 164 deletions
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package src.ex7;
12

23
/**
34
* The Discount System: Customer.
@@ -22,7 +23,7 @@ public boolean isMember() {
2223
}
2324

2425
public void setMember(boolean member) {
25-
this.member= member;
26+
this.member = member;
2627
}
2728

2829
public String getMemberType() {

src/ex7/CustomerTest.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package src.ex7;
2+
3+
import static org.junit.Assert.*;
4+
// import static org.junit.Assert.assertEquals;
5+
// import org.junit.AfterClass;
6+
// import org.junit.BeforeClass;
7+
import org.junit.Test;
8+
import org.junit.Ignore;
9+
import org.junit.runner.RunWith;
10+
import org.junit.runners.JUnit4;
11+
import org.junit.runners.Parameterized;
12+
import org.junit.runners.Parameterized.Parameters;
13+
14+
@RunWith(Parameterized.class)
15+
public class CustomerTest
16+
{
17+
private Customer customer;
18+
private String name;
19+
20+
@Parameters
21+
public static Collection<Object[]> data()
22+
{
23+
return Arrays.asList(new Object[][] {
24+
{ "Jhon" }, { "Doo" }, { "Test" }
25+
});
26+
}
27+
28+
public CustomerTest(String name) {
29+
this.name = name;
30+
this.customer = new Customer(name);
31+
}
32+
33+
@Test
34+
public void testGetName()
35+
{
36+
assertEquals("Result", name, customer.getName());
37+
}
38+
39+
@Test
40+
public void testIsMember()
41+
{
42+
assertEquals("Result", false, customer.isMember());
43+
}
44+
45+
@Test
46+
public void testGetMemberType()
47+
{
48+
assertEquals("Result", "", customer.getMemberType());
49+
}
50+
}

src/ex7/Discount.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package src.ex7;
2+
3+
/**
4+
* The Discount System: Discount.
5+
*/
6+
public class Discount
7+
{
8+
private static double serviceDiscountPremium = 0.2;
9+
private static double serviceDiscountGold = 0.15;
10+
private static double serviceDiscountSilver = 0.1;
11+
12+
private static double productDiscountPremium = 0.1;
13+
private static double productDiscountGold = 0.1;
14+
private static double productDiscountSilver = 0.1;
15+
16+
public static double getServiceDiscountRate(String type) {
17+
switch(type.toUpperCase()) {
18+
case "PREMIUM": return serviceDiscountPremium;
19+
case "GOLD": return serviceDiscountGold;
20+
case "SILVER": return serviceDiscountSilver;
21+
}
22+
return 0.0;
23+
}
24+
25+
public static double getProductDiscountRate(String type) {
26+
switch(type.toUpperCase()) {
27+
case "PREMIUM": return productDiscountPremium;
28+
case "GOLD": return productDiscountGold;
29+
case "SILVER": return productDiscountSilver;
30+
}
31+
return 0.0;
32+
}
33+
}
-1.31 KB
Binary file not shown.

src/ex7/DiscountSystem/Customer.ctxt

Lines changed: 0 additions & 16 deletions
This file was deleted.
-491 Bytes
Binary file not shown.

src/ex7/DiscountSystem/CustomerTest.ctxt

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/ex7/DiscountSystem/Discount.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/ex7/DiscountSystem/README.TXT

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/ex7/DiscountSystem/Visit.class

-1.37 KB
Binary file not shown.

0 commit comments

Comments
 (0)