Answer to Question #152284 in Java | JSP | JSF for Hamza saeed

Question #152284
Write the definition of a class that has the following properties:
a. The name of the class is Stock.
b. The class Stock has four instance variables: name of type String,
previousPrice and closingPrice of type double, and
numberOfShares of type int.
1
Expert's answer
2020-12-23T06:58:30-0500
public class Stock {
	private String name;
	private double previousPrice;
	private double closingPrice;
	private int numberOfShares;


	public Stock() {


	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public double getPreviousPrice() {
		return previousPrice;
	}


	public void setPreviousPrice(double previousPrice) {
		this.previousPrice = previousPrice;
	}


	public double getClosingPrice() {
		return closingPrice;
	}


	public void setClosingPrice(double closingPrice) {
		this.closingPrice = closingPrice;
	}


	public int getNumberOfShares() {
		return numberOfShares;
	}


	public void setNumberOfShares(int numberOfShares) {
		this.numberOfShares = numberOfShares;
	}


	@Override
	public String toString() {
		return "Stock [name=" + name + ", previousPrice=" + previousPrice + ", closingPrice=" + closingPrice
				+ ", numberOfShares=" + numberOfShares + "]";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog