CS_1C Homework 9-Abstact Classes & Virtual Functions Solved

35.00 $

Category:

Description

5/5 - (1 vote)

HW09 – Abstract Classes & Virtual Functions

  1. Create an abstract class called Shape with pure virtual members called calcPerimeter and calcArea. Create subclasses of Shape called Rectangle and Triangle that inherited the pure virtual members above.
  2. Write two non-member functions called printPerimeter and printArea that call the methods calcPerimeter and calcArea respectfully.
  3. Instantiate a Rectangle and a Triangle object.
  4. Input the length and width of a rectangle and then call the functions printPerimeter and printArea.
  5. Input the length of the three sides of a triangle and then call the functions printPerimeter and printArea.
  6. Output the perimeter and area of the rectangle and triangle objects.

Use the command script to capture your interaction compiling and running the program, including all operations, as shown below:

CS1C Fall 2018 TTH HW09 50pts Due: Th 10/11/2018

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ script hw09.scr Script started, file is hw09.scr cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ date

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ ls -l

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ make all

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ ls -l

HW09 – Abstract Classes & Virtual Functions [50 pts]

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ ./hw09

 

… // print out output from steps 4 thru 6

 

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ exit Script done, file is hw09.scr

cs1c@cs1c-VirtualBox ~/cs1c/hw/09 $ make tar

 

 

  • Abstact-Classes-Virtual-Functions-nopfii.zip