Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Stock here.
- *
- * @author Quinn Souza
- * @version 2/17/19
- */
- public class Stock
- {
- // instance variables - replace the example below with your own
- private string symbol;
- private double price;
- private double bypercent
- /**
- * Constructor for objects of class Stock
- */
- public Stock(String sym, double currentprice)
- {
- // initialise instance variables
- symbol = sym;
- price = currentprice;
- }
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public String getSymbol()
- {
- return symbol;
- }
- public double getPrice()
- {
- return price;
- }
- public void changePrice(double byPercent)
- {
- if bypercent < 0
- {
- double percent1 = (bypercent/100) * currentprice;
- currentprice = doubleprice - percent1;
- }
- else
- {
- double percent2 = (bypercent/100) * currentprice;
- currentprice = doubleprice + percent2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement