-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ac94649
Showing
16 changed files
with
443 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>PharmacyInvtManager</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package MainClasses; | ||
|
||
public abstract class Bulk { | ||
private int expDate; | ||
private int amount; | ||
private int sizeOfCans; //small, med, large etc. | ||
|
||
public Bulk(int expDate, int amount, int sizeOfCans) { | ||
this.expDate = expDate; | ||
this.amount = amount; | ||
this.sizeOfCans = sizeOfCans; | ||
} | ||
|
||
public int getAmount(){ | ||
return amount; | ||
} | ||
|
||
public int getSizeType(){ | ||
return sizeOfCans; | ||
} | ||
|
||
public int getExpDate(){ | ||
return expDate; | ||
} | ||
|
||
public void setAmount(int amount){ | ||
this.amount = amount; | ||
} | ||
|
||
public void decrementExpDate(){ | ||
expDate--; | ||
} | ||
|
||
//getters and setters | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package MainClasses; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class BulkIterator implements Iterator { | ||
private ArrayList<Bulk> list; | ||
private int position = 0; | ||
|
||
public BulkIterator(ArrayList<Bulk> list) { | ||
this.list = list; | ||
} | ||
|
||
public boolean hasNext() { | ||
if(position < list.size()) | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
public Object next() { | ||
Bulk bulk = list.get(position); | ||
|
||
position += 1; | ||
|
||
return bulk; | ||
} | ||
|
||
//Remove the current bulk | ||
public void removeCurrent(){ | ||
list.remove(position-1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package MainClasses; | ||
|
||
public abstract class BulkStore { | ||
|
||
public BulkStore() { | ||
} | ||
|
||
public Bulk orderBulk(int expDate, int amount, int sizeOfCans){ | ||
return createBulk(expDate, amount, sizeOfCans); | ||
} | ||
|
||
//abstract method | ||
protected abstract Bulk createBulk(int expDate, int amount, int sizeOfCans); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package MainClasses; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Clock implements ClockObservable { | ||
private ArrayList<ClockObserver> observers = new ArrayList<ClockObserver>(); | ||
|
||
@Override | ||
public void addObserver(ClockObserver o) { | ||
observers.add(o); | ||
} | ||
|
||
@Override | ||
public void deleteObserver(ClockObserver o) { | ||
observers.remove(o); | ||
} | ||
|
||
@Override | ||
public void notifyObservers() { | ||
for(ClockObserver o : observers) | ||
o.update(); | ||
} | ||
|
||
public void aDayHasPassed(){ | ||
notifyObservers(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package MainClasses; | ||
|
||
public interface ClockObservable { | ||
void addObserver(ClockObserver o); | ||
void deleteObserver(ClockObserver o); | ||
void notifyObservers(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package MainClasses; | ||
|
||
public interface ClockObserver { | ||
void update(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package MainClasses; | ||
|
||
public interface Iterator { | ||
boolean hasNext(); | ||
Object next(); | ||
void removeCurrent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package MainClasses; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Medication implements ClockObserver{ | ||
private String name; | ||
private int stock = 0; | ||
private int overFlag; | ||
private int lowFlag; | ||
private int sold = 0; //This will be needed to keep track of popular medications. The ones that sell the most. | ||
private ArrayList<Bulk> bulks = new ArrayList<Bulk>(); | ||
|
||
public Medication(String name, int overFlag, int lowFlag) { | ||
this.name = name; | ||
this.overFlag = overFlag; | ||
this.lowFlag = lowFlag; | ||
} | ||
|
||
public String getName(){ | ||
return name; | ||
} | ||
|
||
public int getStock(){ | ||
return stock; | ||
} | ||
|
||
public int getSold(){ | ||
return sold; | ||
} | ||
|
||
public void addBulk(Bulk bulk){ | ||
bulks.add(bulk); | ||
stock += bulk.getAmount(); | ||
|
||
if(stock >= overFlag){ | ||
System.out.println("Medication " + getName() + | ||
" is overstocked with " + getStock() + " items." ); | ||
} | ||
} | ||
|
||
public void saleMade(int sold){ | ||
this.sold += sold; | ||
this.stock -= sold; | ||
|
||
if(stock <= lowFlag){ | ||
System.out.println("Medication " + getName() + | ||
" is low on stock with " + getStock() + " items."); | ||
} | ||
} | ||
|
||
//required from interface Aggregate | ||
public Iterator createIterator(){ | ||
return new BulkIterator(bulks); | ||
} | ||
|
||
//required from interface ClockObserver | ||
public void update() { | ||
System.out.println("Daily alerts for stock on " + getName() + ":"); | ||
|
||
Iterator bulkIterator = createIterator(); | ||
|
||
while(bulkIterator.hasNext()){ | ||
Bulk bulk = (Bulk) bulkIterator.next(); | ||
bulk.decrementExpDate(); | ||
|
||
if(bulk.getExpDate() <= 0){ | ||
System.out.println("A Bulk has expired!"); //TODO Ask user to remove bulk. | ||
bulkIterator.removeCurrent(); | ||
stock -= bulk.getAmount(); | ||
//how do we update over total stock in PharmacyManager? | ||
//reference to PharmacyManager or Clock? | ||
} | ||
|
||
if(bulk.getExpDate() <= 7) | ||
System.out.println("A Bulk is about to expire in " + bulk.getExpDate() + " days."); | ||
|
||
} | ||
|
||
if(stock >= overFlag) | ||
System.out.println("Overstocked with " + getStock() + " items." ); | ||
if(stock <= lowFlag) | ||
System.out.println("Low on stock with " + getStock() + " items."); | ||
|
||
|
||
System.out.println(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package MainClasses; | ||
|
||
public class PharMTest { | ||
|
||
public static void main(String[] args) { | ||
PharmacyManager pm = new PharmacyManager(); | ||
|
||
//TODO Add medications from text file? | ||
pm.addMedication("Aspirin", 50, 20); //Upper limit(notify when overstocked), lower limit (notify when low on stock) | ||
pm.addMedication("Tylenol", 50, 20); | ||
|
||
pm.insertBulk("Aspirin", 15, 30, 1); | ||
pm.insertBulk("Aspirin", 20, 35, 1); | ||
pm.insertBulk("Tylenol", 8, 30, 1); // (name, expDate, amount, size) | ||
|
||
//pm.displayMyStock(); | ||
|
||
//System.out.println("leftover: " + pm.purchased("Aspirin", 15, 1)); | ||
//System.out.println("leftover: " + pm.purchased("Aspirin", 15, 1)); | ||
//System.out.println("leftover: " + pm.purchased("Aspirin", 15, 1)); | ||
//System.out.println("leftover: " + pm.purchased("Aspirin", 15, 1)); | ||
//System.out.println("leftover: " + pm.purchased("Aspirin", 15, 1)); | ||
|
||
pm.displayMyStock(); | ||
|
||
pm.aDayHasPassed(); | ||
|
||
pm.displayMyStock(); | ||
} | ||
|
||
} |
Oops, something went wrong.