Problem

Write a Compass class. A compass provides bearings. A bearing is a measure of direction as...

Write a Compass class. A compass provides bearings. A bearing is a measure of direction as indicated by clockwise rotation around a circle. There are 360 degrees in a bearing, and within each degree are 60 minutes. Thus, a legal bearing would be 270 degrees, 36 minutes (approximately due west). There are never more than 359 degrees in a bearing or more than 59 minutes in a bearing. Both degrees and minutes are integer values. Include the following methods:

(a) __init__ ,__ str__ ,__ repr__ .

(b) Addition allows for both bearing-to-bearing operations and bearing-to-integer operations. If one argument is an integer, the integer is assumed to represent degrees. Addition should be commutative!

(c) Output should always be rounded to the minute.

(d) If inappropriate values are passed to the constructor, the created bearing instance should get a value of 0 degrees, 0 minutes.

Include sample code that uses your class and demonstrates the use of all methods as well as error handling.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT