Tutorial 2: On Objects & Classes, Inheritance and Polymorphism
Tutorial 2: On Objects & Classes, Inheritance and Polymorphism
28 March 2017
Lectured by Jerelyn Pillay and Alicia Nair
1. Develop a java application. Your application should have two classes, a Stock class and a
test/main class. Design a class named Stock that contains:
A string data field named symbol for the stocks symbol.
A string data field named name for the stocks name.
A double data field named previousClosingPrice that stores the stock price for the
previous day.
A double data field named currentPrice that stores the stock price for the current
time.
A constructor that creates a stock with the specified symbol and name.
A method named getChangePercent() that returns the percentage changed from
previousClosingPrice to currentPrice.
Create a test/main class to create your Stock objects and invoke your methods.
2. Develop an application to manage a database of multimedia items. The user has many
multimedia items that include audio CDs, DVDs and PC games. The application/project
must allow the user to :
Store his multimedia items
Search through the database of stored items to find particular items.
Print out items
1. Create a project called DOME, within that create a package called dome.
2. Write a class called Item. The Item class represents all that is common between various
multimedia items. It should have the following attributes :