讲解Inheritance、辅导C/C++编程、C/C++程序语言讲解、辅导software
- 首页 >> C/C++编程Assignment 5- Inheritance
Assignment Overview
This assignment aims at understanding class hierarchies and two ways of software
reusability, i.e. composition and inheritance, and master the definition of the classes
derived from existing classes, accessing of class members in different inheritance and
overriding member functions of derived classes. The following steps of coding a program
are
1. Problem statement: formulate the problem.
2. Analysis and design: describing the properties of the class by natural language.
3. Implementation: Defining the constructor/destructor of derived classes and
overriding member functions of derived classes.
4. Testing: explain how you have tested and verified your C++ program.
What should be submitted?
A short report (up to a few pages of texts plus C++ source codes) detailing for all the
questions of the assignment. The answer for each question should follow the above five
steps:
1. Steps 1 and 2. (20% of the total marks for that question)
2. Step 3 (implementation): your C++ source code including the comments. (60%)
3. Step 4 (testing): you will explain how you have tested the correctness of your C++
program and will include some sample runs of your C++ Programs. (20%).
Testing result must be shown by screenshot.
The report is written in Microsoft Word format. The report is submitted to website:
www.cs-sut.com.
Problem
Given the class hierarchy described by the UML diagram (on the next page).
(1) Define the Time class and its derived class ExtTime according to the UML diagram.
(2) Design an iWatch class that has a name and an ExtTime class object. The iWatch class
has the following operations:
a) Show the current time in china;
b) Show the time in another zone corresponding to the current time.
(3) Write a test program that tests the iWatch class.
(4) Draw a UML diagram having the Time, ExtTime and iWatch classes