diff --git a/.gitignore b/.gitignore index b6e4761..dbb8fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,7 @@ dmypy.json # Pyre type checker .pyre/ + +# Replit stuff +replit.nix +.replit diff --git a/instructions.md b/instructions.md new file mode 100644 index 0000000..df71c0c --- /dev/null +++ b/instructions.md @@ -0,0 +1,18 @@ +# Designing a Simple 2d Vector Class + +## Instructions + +- 2/14/23 + - Before changing **anything**, check out a new branch in which to work. + + - Write an `__init__` method for `Vector2d` that has positional parameters for the `x` and `y` components that correspond to the *instance variables* `self.x` and `self.y` + + - Write a `__repr__` method for the `Vector2d` class that returns a string such that `Vector2d(3, 4) == eval(repr(Vector2d(3, 4)))` is `True` + + - Write a `__str__` method for the `Vector2d` class such that `str(Vector2d(3, 4))` would return `'3i + 4j'`. (**i** and **j** are what many physicists and engineers use to denote the x and y directions) + + - Write an `__abs__` function that takes `self` as its only argument and returns the length of the hypotenuse of the right triangle with legs equal to `self.x` and `self.y`. For example, `abs(Vector2d(3, 4))` should return `5.0`. + + - Once you've finished today's work, commit your changes and push them to **your** repository. + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..104be10 --- /dev/null +++ b/main.py @@ -0,0 +1,2 @@ +class Vector2d: + pass \ No newline at end of file