/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/Stock.java |
package com.calebfontenot.lab3_calebfontenot;
@author
public class Stock {
private String symbol;
private String name;
private double previousClosingPrice;
private double currentPrice;
@return
public double getCurrentPrice()
{
return currentPrice;
}
@param
public void setCurrentPrice(double currentPrice)
{
this.currentPrice = currentPrice;
}
@return
public double getPreviousClosingPrice()
{
return previousClosingPrice;
}
@param
public void setPreviousClosingPrice(double previousClosingPrice)
{
this.previousClosingPrice = previousClosingPrice;
}
@return
public String getName()
{
return name;
}
@param
public void setName(String name)
{
this.name = name;
}
@return
public String getSymbol()
{
return symbol;
}
@param
public void setSymbol(String symbol)
{
this.symbol = symbol;
}
public double getChangePercent() {
return this.currentPrice - this.previousClosingPrice;
}
@Override
public String toString()
{
return "Stock{" + "symbol=" + symbol + ", name=" + name + ", previousClosingPrice=" + previousClosingPrice + ", currentPrice=" + currentPrice + "}"+ "\n" + "Change in Percent: " + this.getChangePercent();
}
public static void main(String[] args)
{
Stock stock1 = new Stock();
stock1.setSymbol("ORCL");
stock1.setName("Oracle Corporation");
stock1.setPreviousClosingPrice(34.5);
stock1.setCurrentPrice(34.35);
System.out.println(stock1);
}
}