Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created January 24, 2012 01:11
Show Gist options
  • Save lazypower/1667124 to your computer and use it in GitHub Desktop.
Save lazypower/1667124 to your computer and use it in GitHub Desktop.
Lab4.1
/*
* 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