Commit cf6f4cab authored by RAHUL SHARMA's avatar RAHUL SHARMA

Add JUnit tests

parent 3afa32be
<component name="libraryTable">
<library name="Arquillian JUnit:Release" type="repository">
<properties maven-id="org.jboss.arquillian.junit:arquillian-junit-container:RELEASE" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/junit/arquillian-junit-container/1.2.0.Final/arquillian-junit-container-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/junit/arquillian-junit-core/1.2.0.Final/arquillian-junit-core-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-api/1.2.0.Final/arquillian-test-api-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-api/1.2.0.Final/arquillian-core-api-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-spi/1.2.0.Final/arquillian-test-spi-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-spi/1.2.0.Final/arquillian-core-spi-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-api/1.2.0.Final/arquillian-container-test-api-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-api/1.2.6/shrinkwrap-api-1.2.6.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-spi/1.2.0.Final/arquillian-container-test-spi-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-spi/1.2.0.Final/arquillian-container-spi-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-api-base/2.0.0/shrinkwrap-descriptors-api-base-2.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-impl-base/1.2.0.Final/arquillian-core-impl-base-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-impl-base/1.2.0.Final/arquillian-test-impl-base-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-impl-base/1.2.0.Final/arquillian-container-impl-base-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/config/arquillian-config-api/1.2.0.Final/arquillian-config-api-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/config/arquillian-config-impl-base/1.2.0.Final/arquillian-config-impl-base-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-spi/2.0.0/shrinkwrap-descriptors-spi-2.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-impl-base/1.2.0.Final/arquillian-container-test-impl-base-1.2.0.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.2.6/shrinkwrap-impl-base-1.2.6.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-spi/1.2.6/shrinkwrap-spi-1.2.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="adc67a67-9f57-4ff6-8cd4-578335b241d1" name="Default" comment="" />
<list default="true" id="adc67a67-9f57-4ff6-8cd4-578335b241d1" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/Arquillian_JUnit_Release.xml" />
<change beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change beforePath="" afterPath="$PROJECT_DIR$/src/README.md" />
<change beforePath="" afterPath="$PROJECT_DIR$/src/StockExchangeTest.java" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/OrderMatching.iml" afterPath="$PROJECT_DIR$/OrderMatching.iml" />
<change beforePath="$PROJECT_DIR$/src/Matcher.java" afterPath="$PROJECT_DIR$/src/Matcher.java" />
<change beforePath="$PROJECT_DIR$/src/StockExchange.java" afterPath="$PROJECT_DIR$/src/StockExchange.java" />
<change beforePath="$PROJECT_DIR$/src/TestStockExchange.java" afterPath="" />
<change beforePath="$PROJECT_DIR$/src/Transaction.java" afterPath="$PROJECT_DIR$/src/Transaction.java" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
......@@ -11,14 +22,12 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<splitter split-orientation="horizontal" split-proportion="0.5">
<split-first>
<leaf>
<file leaf-file-name="StockExchange.java" pinned="false" current-in-tab="true">
<file leaf-file-name="StockExchange.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/StockExchange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="457">
<caret line="42" column="30" lean-forward="true" selection-start-line="42" selection-start-column="30" selection-end-line="42" selection-end-column="30" />
<state relative-caret-position="615">
<caret line="41" column="0" lean-forward="false" selection-start-line="41" selection-start-column="0" selection-end-line="41" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
......@@ -26,110 +35,91 @@
</provider>
</entry>
</file>
<file leaf-file-name="Matcher.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Matcher.java">
<file leaf-file-name="StockExchangeTest.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/StockExchangeTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="704">
<caret line="47" column="0" lean-forward="false" selection-start-line="47" selection-start-column="0" selection-end-line="47" selection-end-column="0" />
<folding />
<state relative-caret-position="435">
<caret line="36" column="68" lean-forward="false" selection-start-line="36" selection-start-column="68" selection-end-line="36" selection-end-column="68" />
<folding>
<element signature="e#518#526#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TestStockExchange.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/TestStockExchange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="0" lean-forward="false" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
<file leaf-file-name="README.md" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Transaction.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Transaction.java">
<file leaf-file-name="Matcher.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Matcher.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-52">
<caret line="11" column="27" lean-forward="false" selection-start-line="11" selection-start-column="27" selection-end-line="11" selection-end-column="27" />
<folding>
<element signature="e#355#356#0" expanded="true" />
<element signature="e#387#388#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
<element signature="e#450#451#0" expanded="true" />
<element signature="e#495#496#0" expanded="true" />
<element signature="e#535#536#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#663#664#0" expanded="true" />
<element signature="e#711#712#0" expanded="true" />
<element signature="e#748#749#0" expanded="true" />
<element signature="e#781#782#0" expanded="true" />
<element signature="e#833#834#0" expanded="true" />
<element signature="e#877#878#0" expanded="true" />
<element signature="e#909#910#0" expanded="true" />
<element signature="e#937#938#0" expanded="true" />
<element signature="e#979#980#0" expanded="true" />
<element signature="e#1013#1014#0" expanded="true" />
<element signature="e#1053#1054#0" expanded="true" />
<element signature="e#1089#1090#0" expanded="true" />
<element signature="e#1147#1148#0" expanded="true" />
<element signature="e#1197#1198#0" expanded="true" />
<marker date="1516556048474" expanded="true" signature="265:319" ph="//..." />
</folding>
<state relative-caret-position="180">
<caret line="12" column="0" lean-forward="false" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</split-first>
<split-second>
<leaf>
<file leaf-file-name="Transaction.java" pinned="false" current-in-tab="true">
<file leaf-file-name="Transaction.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Transaction.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1035">
<caret line="69" column="0" lean-forward="false" selection-start-line="69" selection-start-column="0" selection-end-line="69" selection-end-column="0" />
<state relative-caret-position="195">
<caret line="13" column="37" lean-forward="false" selection-start-line="13" selection-start-column="37" selection-end-line="13" selection-end-column="37" />
<folding>
<element signature="e#291#292#0" expanded="true" />
<element signature="e#318#319#0" expanded="true" />
<element signature="e#355#356#0" expanded="true" />
<element signature="e#387#388#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
<element signature="e#450#451#0" expanded="true" />
<element signature="e#495#496#0" expanded="true" />
<element signature="e#535#536#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#663#664#0" expanded="true" />
<element signature="e#711#712#0" expanded="true" />
<element signature="e#748#749#0" expanded="true" />
<element signature="e#781#782#0" expanded="true" />
<element signature="e#833#834#0" expanded="true" />
<element signature="e#877#878#0" expanded="true" />
<element signature="e#909#910#0" expanded="true" />
<element signature="e#937#938#0" expanded="true" />
<element signature="e#979#980#0" expanded="true" />
<element signature="e#1013#1014#0" expanded="true" />
<element signature="e#1053#1054#0" expanded="true" />
<element signature="e#1089#1090#0" expanded="true" />
<element signature="e#1147#1148#0" expanded="true" />
<element signature="e#1197#1198#0" expanded="true" />
<element signature="imports" expanded="true" />
<element signature="e#965#966#0" expanded="true" />
<element signature="e#992#993#0" expanded="true" />
<element signature="e#1029#1030#0" expanded="true" />
<element signature="e#1061#1062#0" expanded="true" />
<element signature="e#1093#1094#0" expanded="true" />
<element signature="e#1124#1125#0" expanded="true" />
<element signature="e#1169#1170#0" expanded="true" />
<element signature="e#1209#1210#0" expanded="true" />
<element signature="e#1247#1248#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1337#1338#0" expanded="true" />
<element signature="e#1385#1386#0" expanded="true" />
<element signature="e#1422#1423#0" expanded="true" />
<element signature="e#1455#1456#0" expanded="true" />
<element signature="e#1507#1508#0" expanded="true" />
<element signature="e#1551#1552#0" expanded="true" />
<element signature="e#1583#1584#0" expanded="true" />
<element signature="e#1611#1612#0" expanded="true" />
<element signature="e#1653#1654#0" expanded="true" />
<element signature="e#1687#1688#0" expanded="true" />
<element signature="e#1727#1728#0" expanded="true" />
<element signature="e#1763#1764#0" expanded="true" />
<element signature="e#1821#1822#0" expanded="true" />
<element signature="e#1871#1872#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</split-second>
</splitter>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
<option value="Arquillian JUnit Test Class" />
<option value="JUnit4 Test Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
......@@ -142,8 +132,10 @@
<option value="$PROJECT_DIR$/src/NewRequest.java" />
<option value="$PROJECT_DIR$/src/TestStockExchange.java" />
<option value="$PROJECT_DIR$/src/Matcher.java" />
<option value="$PROJECT_DIR$/src/RunStockExchange.java" />
<option value="$PROJECT_DIR$/src/StockExchange.java" />
<option value="$PROJECT_DIR$/src/Transaction.java" />
<option value="$PROJECT_DIR$/src/StockExchangeTest.java" />
</list>
</option>
</component>
......@@ -157,6 +149,7 @@
<option name="width" value="1440" />
<option name="height" value="900" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
......@@ -201,6 +194,16 @@
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="create.test.in.the.same.root" value="true" />
<property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
</component>
<component name="RecentsManager">
<key name="CreateTestDialog.RecentsKey">
<recent name="" />
</key>
<key name="CreateTestDialog.Recents.Supers">
<recent name="" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
......@@ -214,7 +217,7 @@
</list>
</option>
</component>
<component name="RunManager">
<component name="RunManager" selected="JUnit.StockExchangeTest">
<configuration default="true" type="Applet" factoryName="Applet">
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
......@@ -222,6 +225,20 @@
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<module />
</configuration>
<configuration name="RunStockExchange" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="RunStockExchange" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="OrderMatching" />
<envs />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
......@@ -236,6 +253,26 @@
<module name="" />
<envs />
</configuration>
<configuration name="StockExchangeTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="OrderMatching" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="StockExchangeTest" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
......@@ -296,6 +333,16 @@
<option name="PROGRAM_PARAMETERS" />
<predefined_log_file id="idea.log" enabled="true" />
</configuration>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="Application.RunStockExchange" />
<item index="1" class="java.lang.String" itemvalue="JUnit.StockExchangeTest" />
</list>
<recent_temporary>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="JUnit.StockExchangeTest" />
<item index="1" class="java.lang.String" itemvalue="Application.RunStockExchange" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
......@@ -310,12 +357,44 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1516537072477</updated>
<workItem from="1516537077933" duration="15290000" />
<workItem from="1516537077933" duration="22831000" />
</task>
<servers />
</component>
<component name="TestHistory">
<history-entry file="StockExchangeTest - 2018.01.22 at 01h 39m 08s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 01h 44m 42s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 01h 58m 22s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 05m 57s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 07m 57s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 07m 59s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 11m 33s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 12m 29s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 12m 34s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
<history-entry file="StockExchangeTest - 2018.01.22 at 02h 15m 01s.xml">
<configuration name="StockExchangeTest" configurationId="JUnit" />
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="15290000" />
<option name="totallyTimeSpent" value="22831000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
......@@ -323,23 +402,24 @@
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32941177" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32941177" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.31176472" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="8" side_tool="false" content_ui="combo" />
......@@ -348,6 +428,35 @@
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
</layout>
<layout-to-restore>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="8" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.31176472" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32941177" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32941177" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
......@@ -356,7 +465,9 @@
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<breakpoint-manager>
<option name="time" value="8" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
......@@ -365,30 +476,31 @@
<state relative-caret-position="90">
<caret line="6" column="23" lean-forward="true" selection-start-line="6" selection-start-column="23" selection-end-line="6" selection-end-column="23" />
<folding>
<element signature="e#291#292#0" expanded="true" />
<element signature="e#318#319#0" expanded="true" />
<element signature="e#355#356#0" expanded="true" />
<element signature="e#387#388#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
<element signature="e#450#451#0" expanded="true" />
<element signature="e#495#496#0" expanded="true" />
<element signature="e#535#536#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#663#664#0" expanded="true" />
<element signature="e#711#712#0" expanded="true" />
<element signature="e#748#749#0" expanded="true" />
<element signature="e#781#782#0" expanded="true" />
<element signature="e#833#834#0" expanded="true" />
<element signature="e#877#878#0" expanded="true" />
<element signature="e#909#910#0" expanded="true" />
<element signature="e#937#938#0" expanded="true" />
<element signature="e#979#980#0" expanded="true" />
<element signature="e#1013#1014#0" expanded="true" />
<element signature="e#1053#1054#0" expanded="true" />
<element signature="e#1089#1090#0" expanded="true" />
<element signature="e#1147#1148#0" expanded="true" />
<element signature="e#1197#1198#0" expanded="true" />
<element signature="imports" expanded="true" />
<element signature="e#965#966#0" expanded="true" />
<element signature="e#992#993#0" expanded="true" />
<element signature="e#1029#1030#0" expanded="true" />
<element signature="e#1061#1062#0" expanded="true" />
<element signature="e#1093#1094#0" expanded="true" />
<element signature="e#1124#1125#0" expanded="true" />
<element signature="e#1169#1170#0" expanded="true" />
<element signature="e#1209#1210#0" expanded="true" />
<element signature="e#1247#1248#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1337#1338#0" expanded="true" />
<element signature="e#1385#1386#0" expanded="true" />
<element signature="e#1422#1423#0" expanded="true" />
<element signature="e#1455#1456#0" expanded="true" />
<element signature="e#1507#1508#0" expanded="true" />
<element signature="e#1551#1552#0" expanded="true" />
<element signature="e#1583#1584#0" expanded="true" />
<element signature="e#1611#1612#0" expanded="true" />
<element signature="e#1653#1654#0" expanded="true" />
<element signature="e#1687#1688#0" expanded="true" />
<element signature="e#1727#1728#0" expanded="true" />
<element signature="e#1763#1764#0" expanded="true" />
<element signature="e#1821#1822#0" expanded="true" />
<element signature="e#1871#1872#0" expanded="true" />
</folding>
</state>
</provider>
......@@ -401,65 +513,87 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/TestStockExchange.java">
<entry file="file://$PROJECT_DIR$/src/Matcher.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="0" lean-forward="false" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
<state relative-caret-position="180">
<caret line="12" column="0" lean-forward="false" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Matcher.java">
<entry file="file://$PROJECT_DIR$/src/Transaction.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="704">
<caret line="47" column="0" lean-forward="false" selection-start-line="47" selection-start-column="0" selection-end-line="47" selection-end-column="0" />
<state relative-caret-position="195">
<caret line="13" column="37" lean-forward="false" selection-start-line="13" selection-start-column="37" selection-end-line="13" selection-end-column="37" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#965#966#0" expanded="true" />
<element signature="e#992#993#0" expanded="true" />
<element signature="e#1029#1030#0" expanded="true" />
<element signature="e#1061#1062#0" expanded="true" />
<element signature="e#1093#1094#0" expanded="true" />
<element signature="e#1124#1125#0" expanded="true" />
<element signature="e#1169#1170#0" expanded="true" />
<element signature="e#1209#1210#0" expanded="true" />
<element signature="e#1247#1248#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1337#1338#0" expanded="true" />
<element signature="e#1385#1386#0" expanded="true" />
<element signature="e#1422#1423#0" expanded="true" />
<element signature="e#1455#1456#0" expanded="true" />
<element signature="e#1507#1508#0" expanded="true" />
<element signature="e#1551#1552#0" expanded="true" />
<element signature="e#1583#1584#0" expanded="true" />
<element signature="e#1611#1612#0" expanded="true" />
<element signature="e#1653#1654#0" expanded="true" />
<element signature="e#1687#1688#0" expanded="true" />
<element signature="e#1727#1728#0" expanded="true" />
<element signature="e#1763#1764#0" expanded="true" />
<element signature="e#1821#1822#0" expanded="true" />
<element signature="e#1871#1872#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/RunStockExchange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="28" lean-forward="true" selection-start-line="6" selection-start-column="28" selection-end-line="6" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/StockExchange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="457">
<caret line="42" column="30" lean-forward="true" selection-start-line="42" selection-start-column="30" selection-end-line="42" selection-end-column="30" />
<state relative-caret-position="615">
<caret line="41" column="0" lean-forward="false" selection-start-line="41" selection-start-column="0" selection-end-line="41" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Transaction.java">
<entry file="file://$PROJECT_DIR$/src/StockExchangeTest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1035">
<caret line="69" column="0" lean-forward="false" selection-start-line="69" selection-start-column="0" selection-end-line="69" selection-end-column="0" />
<state relative-caret-position="435">
<caret line="36" column="68" lean-forward="false" selection-start-line="36" selection-start-column="68" selection-end-line="36" selection-end-column="68" />
<folding>
<element signature="e#291#292#0" expanded="true" />
<element signature="e#318#319#0" expanded="true" />
<element signature="e#355#356#0" expanded="true" />
<element signature="e#387#388#0" expanded="true" />
<element signature="e#419#420#0" expanded="true" />
<element signature="e#450#451#0" expanded="true" />
<element signature="e#495#496#0" expanded="true" />
<element signature="e#535#536#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#663#664#0" expanded="true" />
<element signature="e#711#712#0" expanded="true" />
<element signature="e#748#749#0" expanded="true" />
<element signature="e#781#782#0" expanded="true" />
<element signature="e#833#834#0" expanded="true" />
<element signature="e#877#878#0" expanded="true" />
<element signature="e#909#910#0" expanded="true" />
<element signature="e#937#938#0" expanded="true" />
<element signature="e#979#980#0" expanded="true" />
<element signature="e#1013#1014#0" expanded="true" />
<element signature="e#1053#1054#0" expanded="true" />
<element signature="e#1089#1090#0" expanded="true" />
<element signature="e#1147#1148#0" expanded="true" />
<element signature="e#1197#1198#0" expanded="true" />
<element signature="e#518#526#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
......
......@@ -7,5 +7,16 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Arquillian JUnit:Release" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -12,7 +12,7 @@ public class Matcher {
if (!t1.getStock().equals(t2.getStock())) {
return MatchType.NO_MATCH;
}
if (!t1.getTypeOfRequest().equals(t2.getTypeOfRequest())) {
if (t1.getTypeOfRequest().equals(t2.getTypeOfRequest())) {
return MatchType.NO_MATCH;
}
//current trans is sell
......
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
public class StockExchange {
public void run() throws IOException {
public ArrayList<Transaction> run(ArrayList<String> inputStrings) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Matcher matcher = new Matcher();
boolean shouldContinue = true;
ArrayList<Transaction> transactionList = new ArrayList<>();
while (shouldContinue) {
int inputIndex = 0;
while (shouldContinue && inputIndex < inputStrings.size()) {
// get/parse user input
Transaction currentTransaction = new Transaction();
System.out.println("New Transacrion: \"Time Quantity Price Customer_Id Stock Type\" ");
String inputString = reader.readLine();
StringTokenizer stringTokenizer = new StringTokenizer(inputString);
if (stringTokenizer.hasMoreTokens()) {
currentTransaction.setTime(Integer.parseInt(stringTokenizer.nextToken()));
currentTransaction.setQuantity(Integer.parseInt(stringTokenizer.nextToken()));
currentTransaction.setPricePerUnit(Float.parseFloat(stringTokenizer.nextToken()));
currentTransaction.setCustomerId(stringTokenizer.nextToken());
currentTransaction.setStock(stringTokenizer.nextToken());
currentTransaction.setTypeOfRequest(stringTokenizer.nextToken());
}
String inputString = inputStrings.get(inputIndex);
inputIndex++;
currentTransaction = getTransaction(inputString);
if (!transactionList.isEmpty()) {
......@@ -35,27 +30,26 @@ public class StockExchange {
if (matchType == Matcher.MatchType.FULL_MATCH) {
// modify ith transaction
transactionList.get(i).setQuantity(transactionList.get(i).getQuantity() - currentTransaction.getQuantity() );
if(transactionList.get(i).getQuantity() == 0){
transactionList.get(i).setQuantity(transactionList.get(i).getQuantity() - currentTransaction.getQuantity());
if (transactionList.get(i).getQuantity() == 0) {
transactionList.remove(i);
}
System.out.println(currentTransaction.getCustomerId()+" successfully traded "+ transactionList.get(i).getQuantity()+" stocks with "+transactionList.get(i).getCustomerId());
System.out.println(currentTransaction.getCustomerId() + " successfully traded " + transactionList.get(i).getQuantity() + " stocks with " + transactionList.get(i).getCustomerId());
break;
} else if (matchType == Matcher.MatchType.PARTIAL_MATCH) {
// modify current Transaction
// drop i'th transaction
currentTransaction.setQuantity(currentTransaction.getQuantity() - transactionList.get(i).getQuantity());
transactionList.remove(i);
System.out.println(currentTransaction.getCustomerId()+" successfully traded "+ transactionList.get(i).getQuantity()+" stocks with "+transactionList.get(i).getCustomerId());
System.out.println(currentTransaction.getCustomerId() + " successfully traded " + transactionList.get(i).getQuantity() + " stocks with " + transactionList.get(i).getCustomerId());
} else if (matchType == Matcher.MatchType.NO_MATCH) {
// move on
continue;
}
if(i == transactionList.size()-1 && currentTransaction.getQuantity() > 0) {
if (i == transactionList.size() - 1 && currentTransaction.getQuantity() > 0) {
transactionList.add(currentTransaction);
sortTransactions(transactionList);
break;
}
......@@ -63,16 +57,48 @@ public class StockExchange {
} else {
// add this transaction if list is empty
transactionList.add(currentTransaction);
}
sortTransactions(transactionList);
System.out.println("Do you want to continue? y|n");
String userResponseString = reader.readLine();
if (userResponseString.equals("n")) {
shouldContinue = false;
// System.out.print(transactionList);
}
// System.out.println("Do you want to continue? y|n");
// String userResponseString = reader.readLine();
// if (userResponseString.equals("n")) {
// shouldContinue = false;
// }
}
return transactionList;
}
public void sortTransactions(ArrayList<Transaction> transactionList) {
Collections.sort(transactionList, new Comparator<Transaction>() {
@Override
public int compare(Transaction o1, Transaction o2) {
if (o1.getTime() == o2.getTime()) {
return 0;
} else if (o1.getTime() > o2.getTime()) {
return 1;
} else {
return -1;
}
}
});
}
public Transaction getTransaction(String inputString) {
Transaction currentTransaction = new Transaction();
StringTokenizer stringTokenizer = new StringTokenizer(inputString);
if (stringTokenizer.hasMoreTokens()) {
currentTransaction.setTime(Integer.parseInt(stringTokenizer.nextToken()));
currentTransaction.setQuantity(Integer.parseInt(stringTokenizer.nextToken()));
currentTransaction.setPricePerUnit(Float.parseFloat(stringTokenizer.nextToken()));
currentTransaction.setCustomerId(stringTokenizer.nextToken());
currentTransaction.setStock(stringTokenizer.nextToken());
currentTransaction.setTypeOfRequest(stringTokenizer.nextToken());
}
return currentTransaction;
}
}
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import static org.junit.Assert.*;
public class StockExchangeTest {
private StockExchange stockExchange;
@Before
public void setUp() throws Exception {
stockExchange = new StockExchange();
}
@After
public void tearDown() throws Exception {
}
@Test
public void run() throws IOException {
ArrayList<String> testStrings = new ArrayList<String>();
testStrings.add("1 20 300 C8 Apple Sell");
testStrings.add("10 35 200 C9 Moto Buy");
testStrings.add("9 20 400 C5 Jio Sell");
testStrings.add("7 30 300 C7 Moto Sell");
testStrings.add("8 20 250 C7 Moto Buy");
testStrings.add("2 25 400 C6 Jio Buy");
testStrings.add("12 25 400 C6 Apple Buy");
ArrayList<Transaction> actualList = new ArrayList<>();
// actualList.add(stockExchange.getTransaction("1 20 300 C8 Apple Sell"));
actualList.add(stockExchange.getTransaction("2 5 400 C6 Jio Buy"));
actualList.add(stockExchange.getTransaction("7 30 300 C7 Moto Sell"));
actualList.add(stockExchange.getTransaction("8 20 250 C7 Moto Buy"));
actualList.add(stockExchange.getTransaction("10 35 200 C9 Moto Buy"));
actualList.add(stockExchange.getTransaction("12 5 400 C6 Apple Buy"));
ArrayList<Transaction> resultList = stockExchange.run(testStrings);
for (int i = 0; i < resultList.size(); i++) {
assertEquals(resultList.get(i), actualList.get(i));
}
}
}
\ No newline at end of file
import java.io.IOException;
public class TestStockExchange {
public static void main(String[] args) throws IOException {
StockExchange stockExchange = new StockExchange();
stockExchange.run();
}
}
import java.util.Comparator;
import java.util.Objects;
public class Transaction implements Comparator<Transaction> {
public class Transaction {
private int time;
private int quantity;
......@@ -9,7 +10,26 @@ public class Transaction implements Comparator<Transaction> {
private String stock;
private String typeOfRequest;
private int getTime() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Transaction that = (Transaction) o;
return time == that.time &&
quantity == that.quantity &&
Float.compare(that.pricePerUnit, pricePerUnit) == 0 &&
Objects.equals(customerId, that.customerId) &&
Objects.equals(stock, that.stock) &&
Objects.equals(typeOfRequest, that.typeOfRequest);
}
@Override
public int hashCode() {
return Objects.hash(time, quantity, pricePerUnit, customerId, stock, typeOfRequest);
}
public int getTime() {
return time;
}
......@@ -69,18 +89,5 @@ public class Transaction implements Comparator<Transaction> {
'}';
}
// add comparator
@Override
public int compare(Transaction o1, Transaction o2) {
if(o1.getTime() == o2.getTime()){
return 0;
}
else if(o1.getTime() > o2.getTime()){
return 1;
}
else {
return -1;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment