{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Object Oriented Programming\n",
    "## Homework Assignment\n",
    "\n",
    "####Problem 1\n",
    "Fill in the Line class methods to accept coordinate as a pair of tuples and return the slope and distance of the line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class Line(object):\n",
    "    \n",
    "    def __init__(self,coor1,coor2):\n",
    "        self.coor1 = coor1\n",
    "        self.coor2 = coor2\n",
    "    \n",
    "    def distance(self):\n",
    "        x1,y1 = self.coor1\n",
    "        x2,y2 = self.coor2\n",
    "        return ( (x2-x1)**2 + (y2-y1)**2 )**0.5\n",
    "    \n",
    "    def slope(self):\n",
    "        x1,y1 = self.coor1\n",
    "        x2,y2 = self.coor2\n",
    "        return float((y2-y1))/(x2-x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "coordinate1 = (3,2)\n",
    "coordinate2 = (8,10)\n",
    "\n",
    "li = Line(coordinate1,coordinate2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9.433981132056603"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li.distance()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.6"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li.slope()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "________\n",
    "####Problem 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Fill in the class "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Cylinder(object):\n",
    "    \n",
    "    def __init__(self,height=1,radius=1):\n",
    "        self.height = height\n",
    "        self.radius = radius\n",
    "        \n",
    "    def volume(self):\n",
    "        return self.height * (3.14)* (self.radius)**2\n",
    "    \n",
    "    def surface_area(self):\n",
    "        top = (3.14)* (self.radius)**2\n",
    "        return 2*top + 2*3.14*self.radius*self.height"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "c = Cylinder(2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "56.52"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.volume()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "94.2"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.surface_area()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}