diff --git a/WK4/StockService/out/production/StockService/StockServices/Interval.class b/WK4/StockService/out/production/StockService/StockServices/Interval.class new file mode 100644 index 0000000..5fb785f Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/Interval.class differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockQuote.class b/WK4/StockService/out/production/StockService/StockServices/StockQuote.class new file mode 100644 index 0000000..5bc1e19 Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockQuote.class differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockQuoteApplication.class b/WK4/StockService/out/production/StockService/StockServices/StockQuoteApplication.class new file mode 100644 index 0000000..5b1bdda Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockQuoteApplication.class differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockService.class b/WK4/StockService/out/production/StockService/StockServices/StockService.class new file mode 100644 index 0000000..e3fa9ff Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockService.class differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockServiceFactory.class b/WK4/StockService/out/production/StockService/StockServices/StockServiceFactory.class new file mode 100644 index 0000000..ef2ac61 Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockServiceFactory.class differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockServices.zip b/WK4/StockService/out/production/StockService/StockServices/StockServices.zip new file mode 100644 index 0000000..13b02fc Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockServices.zip differ diff --git a/WK4/StockService/out/production/StockService/StockServices/StockTest.class b/WK4/StockService/out/production/StockService/StockServices/StockTest.class new file mode 100644 index 0000000..25463c2 Binary files /dev/null and b/WK4/StockService/out/production/StockService/StockServices/StockTest.class differ diff --git a/WK4/StockService/src/StockServices/BasicStockService.java b/WK4/StockService/src/StockServices/BasicStockService.java new file mode 100644 index 0000000..2e02cec --- /dev/null +++ b/WK4/StockService/src/StockServices/BasicStockService.java @@ -0,0 +1,26 @@ +package StockServices; + +import java.util.Calendar; + +public class BasicStockService extends StockQuote { + String bssSymbol; + Calendar bssFrom; + Calendar bssUntil; + Interval bssInterval; + + public BasicStockService(String symbol, Calendar from, Calendar until, Interval interval){ + this.bssSymbol = symbol; + this .bssFrom = from; + this.bssUntil = until; + this.bssInterval = interval; + } + public StockQuote getStockQuote(String bssSymbol, Calendar bssFrom, Calendar bssUntil, Interval bssInterval) { + if (bssFrom == null ) + return new StockQuote(bssSymbol); + else if (bssInterval == null) + return new StockQuote(bssSymbol, bssFrom, bssUntil); + else + return new StockQuote(bssSymbol, bssFrom, bssUntil, bssInterval); + } +} + diff --git a/WK4/StockService/src/StockServices/Interval.java b/WK4/StockService/src/StockServices/Interval.java new file mode 100644 index 0000000..ec8416c --- /dev/null +++ b/WK4/StockService/src/StockServices/Interval.java @@ -0,0 +1,31 @@ +package StockServices; + +public class Interval { + + public enum chooseWeek { + WK1, WK2, WK3, WK4 + } + + chooseWeek week; + + public Interval(chooseWeek week) { + this.week = week; + } + + public void weekChosen() { + switch (week) { + case WK1: + System.out.println("Biggest Market Place in the World."); + break; + + case WK2: + System.out.println("Simplest way to manage Money."); + break; + + case WK3: + case WK4: + System.out.println("1st Web 2.0 Company."); + break; + } + } +} \ No newline at end of file diff --git a/WK4/StockService/src/StockServices/StockQuote.java b/WK4/StockService/src/StockServices/StockQuote.java new file mode 100644 index 0000000..55b63f4 --- /dev/null +++ b/WK4/StockService/src/StockServices/StockQuote.java @@ -0,0 +1,49 @@ +package StockServices; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +public class StockQuote implements StockService { + String sqSymbol; + Calendar sqFrom, sqUntil; + Interval sqInterval; + + public StockQuote(String symbol) { + this.sqSymbol = symbol; + } + public StockQuote(String symbol, Calendar from, Calendar until) { + this.sqSymbol = symbol; + this.sqFrom = from; + this.sqUntil = until; + } + public StockQuote(String symbol, Calendar from, Calendar until, Interval interval) { + this.sqSymbol = symbol; + this.sqFrom = from; + this.sqUntil = until; + this.sqInterval = interval; + } + public StockQuote() { + } + + @Override + public StockQuote getQuote(String symbol) { + return new StockQuote(sqSymbol); + } + @Override + public List getQuote(String symbol, Calendar from, Calendar until) { + List stockQuoteList = new ArrayList<>(); + StockQuote stockQuote = new StockQuote(); + StockService stockService = new StockQuote(); + stockService.getQuote(sqSymbol, sqFrom, sqUntil); + stockQuoteList.add(stockQuote); + return stockQuoteList; + } + @Override + public List getQuote(String sqSymbol, Calendar sqFrom, Calendar sqUntil, Interval sqInterval) { + List stockQuoteList = new ArrayList<>(); + StockQuote stockQuote = new StockQuote(sqSymbol, sqFrom, sqUntil, sqInterval); + stockQuoteList.add(stockQuote); + return stockQuoteList; + } +} diff --git a/WK4/StockService/src/StockServices/StockQuoteApplication.java b/WK4/StockService/src/StockServices/StockQuoteApplication.java new file mode 100644 index 0000000..c295b1f --- /dev/null +++ b/WK4/StockService/src/StockServices/StockQuoteApplication.java @@ -0,0 +1,51 @@ +package StockServices; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class StockQuoteApplication { + public static void main(String[] args) throws ParseException { + + String symbol, startDate, endDate; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd"); + + symbol = "ABC"; + + startDate = "2018 01 01"; + Date fromDate = sdf.parse(startDate); + Calendar from = Calendar.getInstance(); + from.setTime(fromDate); + + endDate = "2018 01 07"; + Date toDate = sdf.parse(endDate); + Calendar until = Calendar.getInstance(); + until.setTime(toDate); + + String week = "WK1"; + Interval interval; + + if (week == "WK1") { + interval = new Interval(Interval.chooseWeek.WK1); + interval.weekChosen(); + } + else if (week == "WK2") { + interval = new Interval(Interval.chooseWeek.WK2); + interval.weekChosen(); + } + else if (week == "WK3") { + interval = new Interval(Interval.chooseWeek.WK3); + interval.weekChosen(); + } + else { + interval = new Interval(Interval.chooseWeek.WK4); + interval.weekChosen(); + } + + StockServiceFactory stockServiceFactory = new StockServiceFactory(symbol, from, until, interval); + stockServiceFactory.getStockService(symbol, from, until, interval); + System.out.println(stockServiceFactory); + } +} diff --git a/WK4/StockService/src/StockServices/StockService.java b/WK4/StockService/src/StockServices/StockService.java new file mode 100644 index 0000000..4433baa --- /dev/null +++ b/WK4/StockService/src/StockServices/StockService.java @@ -0,0 +1,39 @@ +package StockServices; + +import java.util.Calendar; +import java.util.List; + +public interface StockService { + /** + * Return the current price for a share of 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 BigDecimal instance + */ + StockQuote getQuote(String symbol); + /** + * Get a historical 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 getQuote(String symbol, Calendar from, Calendar until); + /** + * Get a historical list of stock quotes for the provide symbol + * This method will return one StockQuote per interval specified. + * + *@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 + *@param interval ­ the number of StockQuotes to get. E.g. if Interval.DAILY was specified + *one StockQuote per day will be returned. + * + ​@return a list of StockQuote instances. One for each day in the range specified. + */ + List getQuote(String symbol, Calendar from, Calendar until, Interval interval); +} diff --git a/WK4/StockService/src/StockServices/StockServiceFactory.java b/WK4/StockService/src/StockServices/StockServiceFactory.java new file mode 100644 index 0000000..d8b53e0 --- /dev/null +++ b/WK4/StockService/src/StockServices/StockServiceFactory.java @@ -0,0 +1,15 @@ +package StockServices; + +import java.util.Calendar; + +public class StockServiceFactory{ + public StockServiceFactory() { + } + public StockServiceFactory getStockService(String Symbol, Calendar From, Calendar Until, Interval INTERVAL){ + BasicStockService basicStockService = new BasicStockService(Symbol, From, Until, INTERVAL); + StockServiceFactory stockServiceFactory = new StockServiceFactory(); + basicStockService.getStockQuote(Symbol, From, Until, INTERVAL); + return stockServiceFactory; + /*returs stock service*/ + } +} \ No newline at end of file diff --git a/WK4/StockService/src/StockServices/StockServices.zip b/WK4/StockService/src/StockServices/StockServices.zip new file mode 100644 index 0000000..13b02fc Binary files /dev/null and b/WK4/StockService/src/StockServices/StockServices.zip differ diff --git a/WK4/StockService/src/StockServices/StockTest.java b/WK4/StockService/src/StockServices/StockTest.java new file mode 100644 index 0000000..6852e1e --- /dev/null +++ b/WK4/StockService/src/StockServices/StockTest.java @@ -0,0 +1,38 @@ +package StockServices; + +import org.junit.jupiter.api.Test; + +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() { + } + + @Test + void getQuote4() { + } + + @Test + void getQuote5() { + } +}