Write a program to extend the list class by adding a push method. Vectors, in Physics, are objects that have both magnitude and direction. Design a class to represent vectors. Provide addition and...


Write a program to extend the list class by adding a push method.


Vectors, in Physics, are objects that have both magnitude and direction. Design a class to represent vectors. Provide addition and subtraction operators - remember to adjust directions appropriately.


Write a wholeNumber class. The whole numbers are the nonnegative integers: 0,1,2, . . . Your class must handle addition, subtraction, and multiplication of whole numbers— no division or mixed-type (whole number and integer) operations need be handled. Your class must also handle printing, for example, if x is an instance of the wholeNumber class, you must be able to write: print(x).


Two cases must not be allowed: (1) you must not be able to create a wholeNumber that has a negative value; (2) an arithmetic operation cannot be allowed to have a negative result. In both cases, an error message must be printed.


Remember that arithmetic must return a whole number. That is, if x and y are whole numbers, the result of x + y must be a whole number.


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

Nov 19, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here