70 likes | 173 Views
This document outlines a design approach for creating a straightforward stock quote finder app. The app's primary function is to retrieve and display stock quotes upon startup using a simple "Get" command for data handling. It emphasizes efficient data retrieval from a specific URL with appropriate exception handling for invalid stock tickers. The initial implementation offers room for improvement, such as providing additional quotes at startup, incorporating predictive text for ticker input, and displaying related stock quotes from comparable corporations.
E N D
Design Approach • Wanted simple stock quote finder to check stocks • Find and display a certain stock quote on startup • Use simple “Get” command to both get and post data • Grab source code and place it into one giant string to parse • Exception handling for invalid stock tickers
Data Retrieval http://research.scottrade.com/public/stocks/snapshot/snapshot.asp?symbol=(Ticker Symbol) utils_.doGet((urlString + ticker), this); String SourceResponse = new String(utils_.responseToString(resp)); Did I get it?!? <link href=\"/public/common/style/stocks.css\” -NO
Data Retrieval Cont’d tickerIndex = SourceResponse .indexOf("<td class=\"info\" valign=\"bottom\">"); tickerIndex += 33; String theQuote = SourceResponse.substring(tickerIndex, tickerIndex + 6); // Clean up the stock quote. if (theQuote.endsWith("<")) finalQuote = theQuote.substring(0, 5); else if (theQuote.endsWith("/")) finalQuote = theQuote.substring(0, 4); else if (theQuote.endsWith("s")) finalQuote = theQuote.substring(0, 3); else finalQuote = theQuote;
Room for Improvement • Have a larger number of quotes provided at startup of app. • Provide predictive text to determine what ticker the user is trying to input • Provide quotes of corporations similar to the provided ticker (AMD & INTC)