Skip to content
Open

WK3 #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions BasicStockService.java
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) {
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;
}
}

15 changes: 15 additions & 0 deletions StockQuote.java
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;
}
}
35 changes: 35 additions & 0 deletions StockQuoteApplication.java
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);
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();
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);
}
}
29 changes: 29 additions & 0 deletions StockService.java
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);
}
14 changes: 14 additions & 0 deletions StockServiceFactory.java
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){
BasicStockService BSS = new BasicStockService();
StockQuote SQ;
SQ = (StockQuote) BSS.getQuote(symbol, fromDate, toDate);
return SQ;
/*returs stock service*/
}
}
28 changes: 28 additions & 0 deletions StockTest.java
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() {
}
}