For the previous closing price and current price. We want to make these get and set methods for all of the data, so that's what we want to do. The symbol is the same as the simple past in and the name is the same as the name passed in. We want to give the following for this case. There is a private string for the name and then we have the previous closing price which is double and the current price which is also double. This wants to be simple, so it's a private string. The string says that the symbol of a stock is in it. The first thing it asks us to do is to create a couple of fields, such as symbol, name, previous closing price, current price and so on. ![]() We want to create a stock class and associate all these data and methods and then test it out. Display the symbol and name of the company, the previous and current prices and price-change percentage. Display the symbol and name of the company, the previous and current prices and price-change percentage.Īdd code to create another Stock object with the stock symbol ORCL, the name Oracle Corporation/ PreviousClosingPrice is a private double data area that stores the stock price for the previous day.ĬurrentPrice is a private double data area that stores the stock price at the current time.Ī constructor for creating a stock with the given symbol and name.įor the data fields, there are accessor methods (get-methods).įor the data fields, there is a mutator method (set-methods).Ī method named getChangePercent()that returns the percentage changed from previousClosingPrice to currentPrice.įormula:perc_change = (current price - previous closing price) / previous closing price x 100Ĭreate a test class named testStockthat creates a Stockobject with the stock symbol SUNW, the name Sun Microsystems Inc., and the previous closing price of 100. The stock's name is stored in a private string data field called name. The symbol of the stock is stored in a private string data field called symbol. TotalĬreate a Stock object class that contains the following information: Run and test your program and make sure it works. That whenever you click a single leaf, this single leaf will changeĬolor(change image), and all other leaves does not change colors Now you need to supply code in method checkMouseClick(), so One block comment can comment out multiple lines (a block)Īfter you place the block comment as indicated, methodĬheckMouseClick in line 47 has an empty body.Ĥ. ** line 49 to 58 goes between this block comment. use block comment below to comment out line 49 to 58 of Preference, and then check the “Display Line Numbers” box.ģ. ![]() The line numbers of the source code are not being displayedĪlready, then in Greenfoot source code editor, click menu Option à Open this project in Greenfoot IDE and then double clickĬlass Block to view this class in Greenfoot source code editor. JohnDoeAutumnClickB, where JohnDoe shouldĢ. In Windows Filer Explorer or Mac Finder, make a copy of theįolder “autumn-2”, and name the copy folder as Based on the existing Greenfoot scenario “autumn-2” in textbookġ.
0 Comments
Leave a Reply. |