Assignment 3
- Discuss both the advantages and disadvantages of inheritance. Why is over-use of inheritance considered harmful?
- Summarize the major differences between Java and C++.
- Implement a class in Java, C++, or C#, named Rational, for reduced-form rational numbers that provides the following operations: add, sub, mul, and div.
- Implement a class in Java, C++, or C#, named Car, with the following behavior. A car has a certain fuel efficiency (measured in miles/gallon) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method 'drive' that simulates driving the car for a certain distance, reducing the fuel level in the gas tank, and methods 'getGas', to return the current fuel level, and 'addGas' to tank up.
- Extend the class Stack to provide a new method called reverse that reverses the elements on the stack.