3.3. Exercises¶
-
Write an equals method for the fraction class that returns true is two fractions are equal and false otherwise.
-
Write sub, mul, and div for the Fraction class.
-
Write a class that represents a Rectangle. Your constructor should take a length and a width. Write an area method that returns the area of the rectangle.
-
Write a class the old way that represents a Rectangle. Your constructor should take a length and a width. Write an area method that returns the area of the rectangle.
-
Write a class
Stack
that implements the stack data type, with a push, pop, peek, size, and isEmpty as the methods.Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
-
Write a class
Queue
that implements the queue data type, with enqueue, dequeue, peek, size, and isEmpty as the methods.
-
Write a class Cat that inherits from Animal.