# William M. Farmer
# 27 November 2010
#
# This is a solution for Lab 10: Unmarked Assignment 6

import math

class Vector:

    def __init__(self, x, y):
        self.xpos = x
        self.ypos = y


    # ACCESSORS

    def getX(self):
        return self.xpos

    def getY(self):
        return self.ypos


    # MUTATORS: none

    
    # ALGEBRAIC METHODS

    def magnitude(self):
        "Computes the magnitude of self."
        return math.sqrt((self.getX() ** 2.0) + (self.getY() ** 2.0))

    def scalarMultiply(self, s):
        "Creates the scalar multiple of s and self."
        return Vector(s * self.getX(), s * self.getY())

    def add(self, v):
        "Creates the sum of self and v."
        return Vector(self.getX() + v.getX(), self.getY() + v.getY())

    def linearCombo(self, v, a, b):
        "Creates the linear combination of self, v, a, and b."
        return self.scalarMultiply(a).add(v.scalarMultiply(b))


# Design Question
# 
# The difference of two Vector object can be created using
# scalarMultiply and add as follows:
# 
# def difference(self,v):
#     return self.add(v.scalarMultiply(-1.0))
# 
# Test Plan
# 
# Test 1 for getX()
# Input: Vector(5,7)
# Expected Output: 5
#
# Test 1 for getY()
# Input: Vector(5,7)
# Expected Output: 7
#
# Test 1 for magnitude()
# Input: Vector(5,10)
# Expected Output: 11.1803
#
# Test 1 for scalarMultiply(s)
# Input: Vector(5,10), 3
# Expected Output: Vector(15,30)
#
# Test 1 for add(v)
# Input: Vector(5,10), Vector(6,4)
# Expected Output: Vector(11,14)
#
# Test 1 for linearCombo(v,a,b)
# Input: Vector(5,10), Vector(14,19), 3, 2
# Expected Output: Vector(43, 68)

# What would be some examples of boundary and abnormal cases?
