diff --git a/.idea/libraries/WifiModem.xml b/.idea/libraries/WifiModem.xml new file mode 100644 index 0000000000000000000000000000000000000000..b2c4e35c9c4aac972eeee214cd9004aec575ac75 --- /dev/null +++ b/.idea/libraries/WifiModem.xml @@ -0,0 +1,9 @@ +<component name="libraryTable"> + <library name="WifiModem"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/Automail/WifiModem.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> +</component> \ No newline at end of file diff --git a/.idea/libraries/WifiModem__2_.xml b/.idea/libraries/WifiModem__2_.xml new file mode 100644 index 0000000000000000000000000000000000000000..b8caf1bc57fdb2db7083028bb52ef96174de65ae --- /dev/null +++ b/.idea/libraries/WifiModem__2_.xml @@ -0,0 +1,9 @@ +<component name="libraryTable"> + <library name="WifiModem (2)"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/Automail/WifiModem.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> +</component> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..009eed143a72d57001ad8c69ae55dae6ff439e74 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_15" project-jdk-name="15" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/Automail/out" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..36c6e50ddd6463bbf14ebd0e8863d52b1599160d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/swen30006-group-work.iml" filepath="$PROJECT_DIR$/.idea/swen30006-group-work.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/swen30006-group-work.iml b/.idea/swen30006-group-work.iml new file mode 100644 index 0000000000000000000000000000000000000000..a6aa54653a07c7d98f20eec312ec1d69b41b53e2 --- /dev/null +++ b/.idea/swen30006-group-work.iml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/Automail/src" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="WifiModem (2)" level="project" /> + </component> +</module> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..d4f4346998ddaeb8d7ac3a74e13ca9352409e871 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ChangeListManager"> + <list default="true" id="f1fdc998-0877-4462-bd63-261035866328" name="Default Changelist" comment="" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="CodeInsightWorkspaceSettings"> + <option name="optimizeImportsOnTheFly" value="true" /> + </component> + <component name="MavenImportPreferences"> + <option name="generalSettings"> + <MavenGeneralSettings> + <option name="mavenHome" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\plugins\maven\lib\maven3" /> + </MavenGeneralSettings> + </option> + </component> + <component name="ProjectId" id="1rSafzfDI3SH3MnHU7Ou2eua9FS" /> + <component name="ProjectViewState"> + <option name="hideEmptyMiddlePackages" value="true" /> + <option name="showLibraryContents" value="true" /> + </component> + <component name="PropertiesComponent"> + <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> + <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$/../Automail-V3.6/Automail/src/simulation/Simulation.java" /> + <property name="project.structure.last.edited" value="Project" /> + <property name="project.structure.proportion" value="0.0" /> + <property name="project.structure.side.proportion" value="0.2" /> + <property name="settings.editor.selected.configurable" value="configurable.group.appearance" /> + </component> + <component name="RunManager" selected="Application.Simulation"> + <configuration name="Simulation" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="simulation.Simulation" /> + <module name="swen30006-group-work" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="WifiModem" type="JarApplication"> + <option name="JAR_PATH" value="$PROJECT_DIR$/Automail/WifiModem.jar" /> + <option name="WORKING_DIRECTORY" value="C:\Users\Stefan\OneDrive\Desktop\swen30006-group-work" /> + <option name="ALTERNATIVE_JRE_PATH" /> + <method v="2" /> + </configuration> + <list> + <item itemvalue="Application.Simulation" /> + <item itemvalue="JAR Application.WifiModem" /> + </list> + </component> + <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="f1fdc998-0877-4462-bd63-261035866328" name="Default Changelist" comment="" /> + <created>1618972051470</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1618972051470</updated> + </task> + <servers /> + </component> +</project> \ No newline at end of file diff --git a/Automail/automail.properties b/Automail/automail.properties index 56172357a52a385ed7e6a225ee94a381c59cc64b..2eba82952a232feb376cfef2ef423dae46b8e931 100644 --- a/Automail/automail.properties +++ b/Automail/automail.properties @@ -12,4 +12,5 @@ Mail_Receving_Length=120 # Robots Robots=3 ChargeThreshold=10 -CommercialDisplay=false +ChargeDisplay=true + diff --git a/Automail/out/production/swen30006-group-work/automail/Automail.class b/Automail/out/production/swen30006-group-work/automail/Automail.class new file mode 100644 index 0000000000000000000000000000000000000000..baa6be4309cf4d1ff4164509836a94ec8a65b972 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/Automail.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/ChargeCalculator.class b/Automail/out/production/swen30006-group-work/automail/ChargeCalculator.class new file mode 100644 index 0000000000000000000000000000000000000000..09d7d3ef5a7db00ccbfbdf82ee5ac980f5302961 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/ChargeCalculator.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/MailItem.class b/Automail/out/production/swen30006-group-work/automail/MailItem.class new file mode 100644 index 0000000000000000000000000000000000000000..84505bc150c5474ed6092607892d215ab7809baf Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/MailItem.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/MailPool$Item.class b/Automail/out/production/swen30006-group-work/automail/MailPool$Item.class new file mode 100644 index 0000000000000000000000000000000000000000..79afe304471aef01482e503707ba658a01baa53d Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/MailPool$Item.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/MailPool$ItemComparator.class b/Automail/out/production/swen30006-group-work/automail/MailPool$ItemComparator.class new file mode 100644 index 0000000000000000000000000000000000000000..490b1b6e9c02a12bd1c99189178c187f7508f03b Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/MailPool$ItemComparator.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/MailPool.class b/Automail/out/production/swen30006-group-work/automail/MailPool.class new file mode 100644 index 0000000000000000000000000000000000000000..2d36ebcc7e492cc1738d6ccb105ca2de1696c1d8 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/MailPool.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/Robot$1.class b/Automail/out/production/swen30006-group-work/automail/Robot$1.class new file mode 100644 index 0000000000000000000000000000000000000000..f4b86da3a1131e34928f98df00cae486d4e9b951 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/Robot$1.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/Robot$RobotState.class b/Automail/out/production/swen30006-group-work/automail/Robot$RobotState.class new file mode 100644 index 0000000000000000000000000000000000000000..f84c635fb911e7cae6dca4d36b5c49295d8b774b Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/Robot$RobotState.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/Robot.class b/Automail/out/production/swen30006-group-work/automail/Robot.class new file mode 100644 index 0000000000000000000000000000000000000000..9919c918bb21e69035b0a3ed5e181144798f9e8f Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/Robot.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/RobotDevice.class b/Automail/out/production/swen30006-group-work/automail/RobotDevice.class new file mode 100644 index 0000000000000000000000000000000000000000..a330cec7f07993afb51d58e1e2b613eff84b7fa8 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/RobotDevice.class differ diff --git a/Automail/out/production/swen30006-group-work/automail/StatisticsLog.class b/Automail/out/production/swen30006-group-work/automail/StatisticsLog.class new file mode 100644 index 0000000000000000000000000000000000000000..b7db77e221ec240e3a6b29c7b94aa2204d88d8a9 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/automail/StatisticsLog.class differ diff --git a/Automail/out/production/swen30006-group-work/exceptions/ExcessiveDeliveryException.class b/Automail/out/production/swen30006-group-work/exceptions/ExcessiveDeliveryException.class new file mode 100644 index 0000000000000000000000000000000000000000..08aad8a953a1254464680270c1dcc4d40aac1f38 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/exceptions/ExcessiveDeliveryException.class differ diff --git a/Automail/out/production/swen30006-group-work/exceptions/ItemTooHeavyException.class b/Automail/out/production/swen30006-group-work/exceptions/ItemTooHeavyException.class new file mode 100644 index 0000000000000000000000000000000000000000..6b63b5aea881527727a30c760caaf22dbecb571c Binary files /dev/null and b/Automail/out/production/swen30006-group-work/exceptions/ItemTooHeavyException.class differ diff --git a/Automail/out/production/swen30006-group-work/exceptions/MailAlreadyDeliveredException.class b/Automail/out/production/swen30006-group-work/exceptions/MailAlreadyDeliveredException.class new file mode 100644 index 0000000000000000000000000000000000000000..e7dd4663015f63d500e69378e627c4a65d8f8bf4 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/exceptions/MailAlreadyDeliveredException.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/Building.class b/Automail/out/production/swen30006-group-work/simulation/Building.class new file mode 100644 index 0000000000000000000000000000000000000000..0f00f6faa3467bbb51db9465461193b9bf4ba825 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/Building.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/Clock.class b/Automail/out/production/swen30006-group-work/simulation/Clock.class new file mode 100644 index 0000000000000000000000000000000000000000..99978284be7def59fa5a50fd67a84ce778567047 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/Clock.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/IMailDelivery.class b/Automail/out/production/swen30006-group-work/simulation/IMailDelivery.class new file mode 100644 index 0000000000000000000000000000000000000000..8f5b988aa4e7f6927f67b513ff8d941c9a06ac42 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/IMailDelivery.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/MailGenerator.class b/Automail/out/production/swen30006-group-work/simulation/MailGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..eb4e0e44c8d243f6b973b0443a2526a028c5d34a Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/MailGenerator.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/Simulation$ReportDelivery.class b/Automail/out/production/swen30006-group-work/simulation/Simulation$ReportDelivery.class new file mode 100644 index 0000000000000000000000000000000000000000..8cb8471f828813435b05978cff702786365c015c Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/Simulation$ReportDelivery.class differ diff --git a/Automail/out/production/swen30006-group-work/simulation/Simulation.class b/Automail/out/production/swen30006-group-work/simulation/Simulation.class new file mode 100644 index 0000000000000000000000000000000000000000..46ae81c465186ef22075e9dbae0efc838419a566 Binary files /dev/null and b/Automail/out/production/swen30006-group-work/simulation/Simulation.class differ diff --git a/Automail/src/automail/Automail.java b/Automail/src/automail/Automail.java index fff050fe088a03f7b4734a1fe61e078169f5e828..eca5758f5acba409fb61e5c8542ba90ed69102dc 100644 --- a/Automail/src/automail/Automail.java +++ b/Automail/src/automail/Automail.java @@ -1,8 +1,6 @@ package automail; -import com.unimelb.swen30006.wifimodem.WifiModem; import simulation.IMailDelivery; -import simulation.Simulation; public class Automail { diff --git a/Automail/src/automail/ChargeCalculator.java b/Automail/src/automail/ChargeCalculator.java index 5ae2ff0df33e182940e9357c9b386f3c1b50c3ba..ded29f87d24e098d2e888e9fedcfb5b3d89fdb4d 100644 --- a/Automail/src/automail/ChargeCalculator.java +++ b/Automail/src/automail/ChargeCalculator.java @@ -4,33 +4,43 @@ import com.unimelb.swen30006.wifimodem.WifiModem; import simulation.Building; import simulation.Simulation; +import java.util.HashMap; + public class ChargeCalculator { public final WifiModem wifiModem; - private double activityUnitPrice; - private double markupPercentage; + private final double activityUnitPrice; + private final double markupPercentage; + + private final HashMap<Integer, Double> floorServiceFeeRecord; public ChargeCalculator(WifiModem wifiModem, double activityUnitPrice, double markupPercentage) { this.wifiModem = wifiModem; this.activityUnitPrice = activityUnitPrice; this.markupPercentage = markupPercentage; + this.floorServiceFeeRecord = new HashMap<>(); } - public double calculateCharge(MailItem item) { int destination = item.destination_floor; double activityUnits = ((2*(destination - Building.MAILROOM_LOCATION)) * Simulation.MOVEMENT_COST) + Simulation.LOOKUP_COST; item.setActivityUnitsUtilized(activityUnits); double activityCost = activityUnits * activityUnitPrice; item.setActivityCost(activityCost); + + double serviceFee = 0.00; double latestServiceFee = wifiModem.forwardCallToAPI_LookupPrice(destination); - double serviceFee = item.getServiceFee(); - if (latestServiceFee >= 0 ) { + if (latestServiceFee >= 0) { item.setSuccessfulLookupCount(item.getSuccessfulLookupCount()+1); - serviceFee = latestServiceFee; item.setServiceFee(latestServiceFee); + floorServiceFeeRecord.put(destination,latestServiceFee); + serviceFee = latestServiceFee; + } else if (floorServiceFeeRecord.containsKey(destination)) { + serviceFee = floorServiceFeeRecord.get(destination); + item.setServiceFee(serviceFee); } - double charge = (activityCost + serviceFee) * (1 + markupPercentage); + double cost = (activityCost + serviceFee); + double charge = cost * (1 + markupPercentage); item.setCharge(charge); return charge; } diff --git a/Automail/src/automail/MailPool.java b/Automail/src/automail/MailPool.java index 9d3ce33a9aa315fd573a5a33aa5f1aae19d56b6d..de0f10d98915bb694d50585bb18af4f8aa741290 100644 --- a/Automail/src/automail/MailPool.java +++ b/Automail/src/automail/MailPool.java @@ -1,7 +1,6 @@ package automail; import exceptions.ItemTooHeavyException; -import simulation.Building; import java.util.Comparator; import java.util.LinkedList; @@ -104,17 +103,6 @@ public class MailPool { } } - public double calculateCharge(int itemIndex, double serviceFee, double activityUnitPrice, double markupPercentage){ - double robotsMovement = 5.0D; - double remoteLookup = 0.1D; - int destination = pool.get(itemIndex).destination; - double activityUnits = ((destination - Building.MAILROOM_LOCATION) * robotsMovement) + remoteLookup; - double activityCost = activityUnits * activityUnitPrice; - double charge = (activityCost + serviceFee) * (1 + markupPercentage); - return charge; - } - - /** * load up any waiting robots with mailItems, if any. */ diff --git a/Automail/src/automail/RobotDevice.java b/Automail/src/automail/RobotDevice.java index 21ac18e7b71501b27505b52982fb6390ee4f15e7..6a9bdb6805eebf7e4663ec1dd0ee9d4138187ad9 100644 --- a/Automail/src/automail/RobotDevice.java +++ b/Automail/src/automail/RobotDevice.java @@ -1,6 +1,5 @@ package automail; -import com.unimelb.swen30006.wifimodem.WifiModem; import simulation.Simulation; public class RobotDevice { diff --git a/Automail/src/simulation/Simulation.java b/Automail/src/simulation/Simulation.java index 3fe8e05979e29faf89fb409bb33c1b673132d247..9442ce81accefcc0f573c1d036b5386b21ba3ffd 100644 --- a/Automail/src/simulation/Simulation.java +++ b/Automail/src/simulation/Simulation.java @@ -99,7 +99,7 @@ public class Simulation { if(mailPool.isNewItem(i)) { double charge = chargeCalculator.calculateCharge(mailPool.getItem(i)); mailPool.setItemCharge(i, charge); - mailPool.getItemInfo(i); + // mailPool.getItemInfo(i); debugging print } } // Priority sort the items @@ -122,7 +122,6 @@ public class Simulation { } // Simulation is finished. print results printResults(); - System.out.println(wModem.Turnoff()); // } /*---------------------------------------------------------------------------------------------------------------*/ @@ -130,18 +129,18 @@ public class Simulation { static private Properties setUpProperties() throws IOException { Properties automailProperties = new Properties(); // Default properties - automailProperties.setProperty("Robots", "Standard"); - automailProperties.setProperty("Floors", "10"); - automailProperties.setProperty("Mail_to_Create", "80"); - automailProperties.setProperty("ChargeThreshold", "0"); - automailProperties.setProperty("ChargeDisplay", "true"); + automailProperties.setProperty("Robots", "Standard"); + automailProperties.setProperty("Floors", "10"); + automailProperties.setProperty("Mail_to_Create", "80"); + automailProperties.setProperty("ChargeThreshold", "0"); + automailProperties.setProperty("ChargeDisplay", "false"); automailProperties.setProperty("Markup_Percentage", "0.059"); automailProperties.setProperty("Activity_Unit_Price", "0.224"); // Read properties FileReader inStream = null; try { - inStream = new FileReader("swen30006-group-work-master/Automail/automail.properties"); + inStream = new FileReader("Automail/automail.properties"); automailProperties.load(inStream); } finally { if (inStream != null) { @@ -171,12 +170,10 @@ public class Simulation { // Charge Display CHARGE_DISPLAY = Boolean.parseBoolean(automailProperties.getProperty("ChargeDisplay")); System.out.println("#Charge Display: " + CHARGE_DISPLAY); - // Markup Percentage - MARKUP_PERCENTAGE = Double.parseDouble(automailProperties.getProperty("Markup_Percentage")); - System.out.println("Markup Percentage: " + MARKUP_PERCENTAGE); - // Activity Unit Price + // Activity unit price ACTIVITY_UNIT_PRICE = Double.parseDouble(automailProperties.getProperty("Activity_Unit_Price")); - System.out.println("Activity_Unit_Price: " + ACTIVITY_UNIT_PRICE); + // Markup percentage + MARKUP_PERCENTAGE = Double.parseDouble(automailProperties.getProperty("Markup_Percentage")); return automailProperties; } /*---------------------------------------------------------------------------------------------------------------*/