Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Stock {
- private String symbol;
- private String name;
- private double prevClosingPrice;
- private double currentPrice;
- public Stock(String vsymbol, String vname) {
- symbol = vsymbol;
- name = vname;
- }
- public double getChangePercent() {
- return ((getCurPrice() - getPrevClosingPrice()))/ getPrevClosingPrice();
- }
- public void setName(String vName) {
- name = vName;
- }
- public void setPrevClsingPrice(double newPreviousClosingPrice) {
- prevClosingPrice = newPreviousClosingPrice;
- }
- public void setCurrentPrice(double newCurrentPrice) {
- currentPrice = newCurrentPrice;
- }
- public String getName() {
- return name;
- }
- public double getPrevClosingPrice() {
- return prevClosingPrice;
- }
- public double getCurPrice() {
- return currentPrice;
- }
- public void displayInfo() {
- System.out.println("Stock name: " + getName());
- System.out.println("previous closing price: " + getPrevClosingPrice());
- System.out.println("Current Price: " + getCurPrice());
- System.out.println("Price change: " + getChangePercent() * 100+"%");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement