-
Notifications
You must be signed in to change notification settings - Fork 0
Wk2 Exersice #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Wk2 Exersice #2
Changes from all commits
d80db10
02e281c
c449e35
160de14
10497a4
5d76b34
bcf90bc
2cf7915
938e47b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?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$/src" isTestSource="false" /> | ||
| </content> | ||
| <orderEntry type="inheritedJdk" /> | ||
| <orderEntry type="sourceFolder" forTests="false" /> | ||
| <orderEntry type="module-library"> | ||
| <library name="JUnit5.0"> | ||
| <CLASSES> | ||
| <root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.0.0/junit-jupiter-api-5.0.0.jar!/" /> | ||
| <root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar!/" /> | ||
| <root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.0.0/opentest4j-1.0.0.jar!/" /> | ||
| <root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.0.0/junit-platform-commons-1.0.0.jar!/" /> | ||
| </CLASSES> | ||
| <JAVADOC /> | ||
| <SOURCES /> | ||
| </library> | ||
| </orderEntry> | ||
| <orderEntry type="library" name="Arquillian JUnit:Latest" level="project" /> | ||
| <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> | ||
| </component> | ||
| </module> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package StockServices; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Calendar; | ||
| import java.util.List; | ||
|
|
||
| public class BasicStockService implements StockService { | ||
| @Override | ||
| public StockQuote getQuote(String symbol) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment your code. |
||
| StockQuote Symbol = new StockQuote(); | ||
| Symbol.getQuote(symbol); | ||
| return Symbol; | ||
| } | ||
|
|
||
| @Override | ||
| public List<StockQuote> getQuote(String symbol, Calendar startCalendar, Calendar endCalendar) { | ||
| StockQuote Quote = new StockQuote(); | ||
| Quote.getQuote(symbol, startCalendar, endCalendar); | ||
| List<StockQuote> SQL = new ArrayList<>(Arrays.asList(Quote)); | ||
| return SQL; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package StockServices; | ||
|
|
||
| import java.util.Calendar; | ||
| import java.util.List; | ||
|
|
||
| public class StockQuote extends StockServiceFactory implements StockService { | ||
| @Override | ||
| public StockQuote getQuote(String symbol) { | ||
| return null; | ||
| } | ||
| @Override | ||
| public List<StockQuote> getQuote(String symbol, Calendar from, Calendar until) { | ||
| return null; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package StockServices; | ||
|
|
||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.Calendar; | ||
| import java.util.Date; | ||
| import java.util.Scanner; | ||
|
|
||
| public class StockQuoteApplication { | ||
| public static void main(String[] args) throws ParseException { | ||
| StockServiceFactory SSF = new StockServiceFactory(); | ||
| Scanner input = new Scanner(System.in); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use whole word variables but the stockservice should only have static methods and a private constructor so that client code can't create instances of them. |
||
| SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd HH:mm:ss"); | ||
|
|
||
| String symbol, startDate, endDate; | ||
|
|
||
| System.out.println("What is the Stocks symbol? "); | ||
| symbol = input.nextLine(); | ||
| System.out.println("View stocks starting at what date? "); | ||
| startDate = input.nextLine(); | ||
| Date fromDate = sdf.parse(startDate); | ||
| Calendar startCalendar = Calendar.getInstance(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. improper indentation. |
||
| startCalendar.setTime(fromDate); | ||
|
|
||
|
|
||
| System.out.println("End list of stocks at what date? "); | ||
| endDate = input.nextLine(); | ||
| Date toDate = sdf.parse(endDate); | ||
| Calendar endCalendar = Calendar.getInstance(); | ||
| endCalendar.setTime(toDate); | ||
|
|
||
| SSF.getStockService(symbol, startCalendar, endCalendar); | ||
| System.out.println(SSF); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package StockServices; | ||
|
|
||
| import java.util.Calendar; | ||
| import java.util.List; | ||
|
|
||
| public interface StockService { | ||
| /** | ||
| * Return the current price for a share o | ||
| f stock for the | ||
| * given symbol | ||
| * @param symbol the stock symbol of the company you want a | ||
| * quote for e.g. APPL for APPLE | ||
| * @return a <CODE>BigDecimal</CODE> instance | ||
| */ | ||
| StockQuote getQuote(String symbol); | ||
| /** | ||
| * Get a histo | ||
| rical list of stock quotes for the provided | ||
| * symbol | ||
| * @param symbol the stock symbol to search for | ||
| * @param from the date of the first stock quote | ||
| * @param until the date of the last stock quote | ||
| * @return a list of StockQuote instan | ||
| ces. | ||
| * One for each day in the range specified. | ||
| */ | ||
| List<StockQuote> getQuote(String symbol, Calendar from, | ||
| Calendar until); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package StockServices; | ||
|
|
||
| import java.util.Calendar; | ||
| import java.util.List; | ||
|
|
||
| public class StockServiceFactory extends BasicStockService{ | ||
| public StockServiceFactory getStockService(String symbol, Calendar fromDate, Calendar toDate){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method should return a StockService not a StockServiceFactory |
||
| BasicStockService BSS = new BasicStockService(); | ||
| StockQuote SQ; | ||
| SQ = (StockQuote) BSS.getQuote(symbol, fromDate, toDate); | ||
| return SQ; | ||
| /*returs stock service*/ | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package StockServices; | ||
|
|
||
| public class StockTest { | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void getQuote() { | ||
| } | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void getQuote1() { | ||
| } | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void getStockService() { | ||
| } | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void getQuote2() { | ||
| } | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void getQuote3() { | ||
| } | ||
|
|
||
| @org.junit.jupiter.api.Test | ||
| void main() { | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't include this file.