Object-Oriented Programming Lab: Inheritance Exercise in CS112L, Assignments of Programming Languages

Instructions for a lab exercise in object-oriented programming (oop) for the cs112l course in the faculty of computer science and engineering. Students are required to create classes 'publication', 'sales', 'book', 'tape', and 'disk' for a publishing company that markets book, audiocassette, and computer disk versions of its works. The classes should include member functions getdata() and putdata(), and the 'book', 'tape', and 'disk' classes should be derived from 'publication'. The 'disk' class should also include an enum type for the disk type: cd or dvd.

Typology: Assignments

2020/2021

Uploaded on 06/14/2021

kiran-shah
kiran-shah 🇵🇰

3

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
FACULTY OF COMPUTER SCIENCE AND ENGINEERING
CS112L Object Oriented Programming
Lab Final
Task : Inheritance
Imagine a publishing company that markets both book and audiocassette versions of its works. Create a
class publication that stores the title (a string) and price (type float) of a publication. Add another base
class sales that holds an array of three floats so that it can record the dollar sales of a particular
publication for the last three months.
From these base classes derive two classes: book, which adds a page count (type int), and tape, which
adds a playing time in minutes (type float).
Assume that the publisher decides to add a third way to distribute books: on computer disk, for those
who like to do their reading on their laptop. Add a disk class that, like book and tape, is derived from
publication. The disk class should incorporate the same member functions as the other classes. The data
item unique to this class is the disk type: either CD or DVD. Use an enum type to store this item. The
user could select the appropriate type by typing c or d.
Each of these classes should have a getdata() function to get its data from the user at the keyboard,
and a putdata() function to display its data.
Write a main() program to test the book , tape and disk classes by creating instances of them and
exercise their input/output capabilities.

Partial preview of the text

Download Object-Oriented Programming Lab: Inheritance Exercise in CS112L and more Assignments Programming Languages in PDF only on Docsity!

FACULTY OF COMPUTER SCIENCE AND ENGINEERING

CS112L Object Oriented Programming Lab Final

Task : Inheritance

Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the title (a string) and price (type float) of a publication. Add another base class sales that holds an array of three floats so that it can record the dollar sales of a particular publication for the last three months. From these base classes derive two classes: book , which adds a page count (type int), and tape, which adds a playing time in minutes (type float). Assume that the publisher decides to add a third way to distribute books: on computer disk, for those who like to do their reading on their laptop. Add a disk class that, like book and tape, is derived from publication. The disk class should incorporate the same member functions as the other classes. The data item unique to this class is the disk type: either CD or DVD. Use an enum type to store this item. The user could select the appropriate type by typing c or d. Each of these classes should have a getdata() function to get its data from the user at the keyboard, and a putdata() function to display its data. Write a main() program to test the book , tape and disk classes by creating instances of them and exercise their input/output capabilities.