{
 "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 coordinates as a pair of tuples and return the slope and distance of the line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "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 (y2-y1)/(x2-x1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "coordinate1 = (3,2)\n",
    "coordinate2 = (8,10)\n",
    "\n",
    "li = Line(coordinate1,coordinate2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9.433981132056603"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li.distance()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.6"
      ]
     },
     "execution_count": 4,
     "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": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Cylinder:\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": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "c = Cylinder(2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "56.52"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.volume()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "94.2"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.surface_area()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}