Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Classes and Data Abstraction User-defined classes Implementation of a class in separate files Learn about inheritance Learn about composition/aggregation Question 1 (40 marks): A

Objectives:

Classes and Data Abstraction User-defined classes Implementation of a class in separate files Learn about inheritance Learn about composition/aggregation

Question 1 (40 marks):

A basic class dateType is designed to implement the date in a program, but the member function setDate does not check whether the date is in valid format.

Rewrite the definition of the function setDate so that the values for the month (1 to 12), day (1 to 31), and year (4 digits) are checked before storing the date into the member variables. Add a member function, isLeapYear, to check whether a year is a leap year.

Sample Output

Question 2 (60 marks):

Part 1:

Define a class addressType, that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables.

Part 2:

Derive a class extPersonType from the class personType. Add a member variable to this class to classify the person as a family member, friend, or business associate. (Hint: you can use an Integer data type to save this information. For example, 1 for family member, 2 for friend and 3 for business associate).

In addition, add a member variable to store the address (using addressType object). Add proper statements on in the main function to test you code. Use constructors to automatically initialize the member variables.

Sample Output:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago