Project 0: Object-oriented design
In this project you'll learn about object-oriented design and how
C++ aids in the process.
Resources for learning about object-oriented desig
- Chapter 9 of the textbook
- A quick introduction the topic. It is just an introduction, by no
means exhaustive. We will not cover it in class; this chapter is
included only for interested students doing this project.
- Introduction to Object-Oriented Programming Using C++
- This site explains C++'s
object-oriented features in much more detail (maybe too much).
I recommend reading Chapter 9 of the course text and then using this
page as a reference.
To get some practice, try doing Exercise 9.1 on page 49. Try
changing the interface to something a little more intuitive.
To add? 5/6
+ 5/6 = 5/6
To add? 3/4
+ 3/4 = 19/12
To add? 1
+ 1 = 31/12
To add? 5/12
+ 5/12 = 3
To add? 0
Some methods that you may want to include in the Rational
class are the following (you may think of others too...):
- A constructor taking no parameters at all.
- A constructor taking a string as a parameter.
- A method for adding a rational to the current number.
- A method for converting a rational to a string.
Go to the project index.