Write an object Conversions with methods inchesToCentimeters, gallonsToLiters, and milesToKilometers.
2.
The preceding problem wasn’t very object-oriented. Provide a general superclass UnitConversion and define objects InchesToCentimeters, GallonsToLiters, and MilesToKilometers that extend it.
3.
Define an Origin object that extends java.awt.Point. Why is this not actually a good idea? (Have a close look at the methods of the Point class.)
4.
Define a Point class with a companion object so that you can construct Point instances as Point(3, 4), without using new.
5.
Write a Scala application, using the App trait, that prints the command-line arguments in reverse order, separated by spaces. For example, scala ReverseHello World should print World Hello.
6.
Write an enumeration describing the four playing card suits so that the toString method returns ♣, ♦, ♥, or ♠.
7.
Implement a function that checks whether a card suit value from the preceding exercise is red.
8.
Write an enumeration describing the eight corners of the RGB color cube. As IDs, use the color values (for example, 0xff0000 for Red).
You are currently reading a PREVIEW of this book.
Get instant access to over
$1 million worth of books and videos.