JGuizard
6/29/2016 - 10:08 AM

An example of class in python.

An example of class in python.


class Triangle():

	h=0.
	w=0.

	def __init__(self,h=0.0,w=0.0):
		self.h=h
		self.w=w

	def setHeight(self,h):
		self.h=h

	def getHeight(self):
		return self.h

	def setWidth(self,w):
		self.w=w

	def getWidth(self):
		return self.w

	def Area(self):
		return self.w*self.h/2.



triangle=Triangle(2.,3.)
print triangle.Area()