Free University of Bolzano/Bozen
Faculty of Computer Science - Bachelor in Applied Computer Science
Bachelor in Production Engineering
Introduction to Programming - A.A. 2004/2005

Exercise
Class ComplexNumber

Part 1: Design and realize a Java class ComplexNumber to represent complex numbers. The functionalities of interest for complex numbers are the following:

Add to the class also a method that does overriding of toString inherited from Object in such a way that it returns a string representing in a suitable way a complex number.

Part 2: Write a public static method external to the class ComplexNumber that, taken a complex number as parameter, returns an integer between 0 and 4 representing the quadrant in which the complex number falls. The result should be 0 in case the complex number lies on one of the two axes.