In object-oriented programming (OOP), private attribute means that we don't want this attribute to be accessed outside t
Posted: Sat May 14, 2022 4:02 pm
In object-oriented programming (OOP), private attribute means that we don't want this attribute to be accessed outside the class object. Explore how to define a private method/ attribute and finish the following questions. Design a class named Stock to represent a company's stock that contains: Initiate method: • A private string data field named symbol that stores stock's symbol • A private string data field named name that stores stock's name • A private fioat data field named previous ClosingPcice that stores previous day's stock price • A private float datafield named current Price that stores current stock price Instance method: • A get method for returning the stock name • A get method for returning the stock symbol • Get and set methods for getting/setting stock's p previous price . Get and set methods for getting/setting stock's current price A method famed getChange Percent() that returns the percentage changed from previous ClosinsPrice to currentPrice After you finish the class construction, write a test program that creates a Stock object with the stock symbol "INTC, the name 'Intel Corporation, the previous closing price of 20.5, and 3 current price of 20.35. Display the price change percentage. Based on the class example you write, please discuss the benefits of OOP 13 the