GRASP-Creator: Initial commit
This commit is contained in:
10
System Development/GRASP-Creator/.classpath
Normal file
10
System Development/GRASP-Creator/.classpath
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
17
System Development/GRASP-Creator/.project
Normal file
17
System Development/GRASP-Creator/.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>GRASP-Creator</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
15
System Development/GRASP-Creator/src/Creator.java
Normal file
15
System Development/GRASP-Creator/src/Creator.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
public class Creator {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
Sale theSale = new Sale();
|
||||||
|
theSale.Order(1, 1);
|
||||||
|
theSale.Order(2, 2);
|
||||||
|
theSale.Order(3, 3);
|
||||||
|
System.out.println("Total = " + theSale.Total());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
public class ProductSpecification {
|
||||||
|
public String description;
|
||||||
|
public double price;
|
||||||
|
public int itemID;
|
||||||
|
|
||||||
|
ProductSpecification(int i) {
|
||||||
|
itemID = i;
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
description = "Hammer";
|
||||||
|
price = 10.85;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
description = "Screw";
|
||||||
|
price = 1.85;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
description = "Nail";
|
||||||
|
price = 0.85;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
System Development/GRASP-Creator/src/Sale.java
Normal file
21
System Development/GRASP-Creator/src/Sale.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Sale {
|
||||||
|
|
||||||
|
List<SalesLineltem> theSale = new ArrayList<>();
|
||||||
|
|
||||||
|
public void Order(int itemNo, int count) {
|
||||||
|
theSale.add( new SalesLineltem(itemNo, count) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Total() {
|
||||||
|
double theTotal = 0.00;
|
||||||
|
for (SalesLineltem item: theSale) {
|
||||||
|
theTotal += item.price * item.numberOrdered;
|
||||||
|
System.out.println(item.description + " " + item.price + " " + item.numberOrdered + " " + item.price*item.numberOrdered);
|
||||||
|
}
|
||||||
|
return theTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
System Development/GRASP-Creator/src/SalesLineltem.java
Normal file
8
System Development/GRASP-Creator/src/SalesLineltem.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
public class SalesLineltem extends ProductSpecification {
|
||||||
|
public int numberOrdered;
|
||||||
|
|
||||||
|
public SalesLineltem(int item, int count) {
|
||||||
|
super(item);
|
||||||
|
numberOrdered = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user