Created
January 24, 2012 01:11
-
-
Save lazypower/1667124 to your computer and use it in GitHub Desktop.
Lab4.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package lab41; | |
/** | |
* | |
* @author charles | |
*/ | |
public class Stock { | |
private String stockSymbol; | |
private String stockName; | |
private double previousClosingPrice; | |
private double currentPrice; | |
public Stock() | |
{ | |
} | |
public Stock(String symbol, String name) | |
{ | |
stockSymbol = symbol; | |
stockName = name; | |
} | |
public String getSymbol() | |
{ | |
return stockSymbol; | |
} | |
public String getName() | |
{ | |
return stockName; | |
} | |
public double getPreviousClosingPrice() | |
{ | |
return previousClosingPrice; | |
} | |
public double getCurrentPrice() | |
{ | |
return currentPrice; | |
} | |
public void setSymbol(String symbol) | |
{ | |
stockSymbol = symbol; | |
} | |
public void setName(String name) | |
{ | |
stockName = name; | |
} | |
public void setPreviousClosingPrice(double price) | |
{ | |
previousClosingPrice = price; | |
} | |
public void setCurrentPrice(double price) | |
{ | |
currentPrice = price; | |
} | |
public double changePercent() | |
{ | |
// calculate the change in percentage | |
return (currentPrice - previousClosingPrice) / previousClosingPrice; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment