示例#1
0
文件: lab4_tests.py 项目: ch-bby/R-2
"""

from complex import Complex
from shapes import Rectangle, Circle
import random

# Test attributes of the circle class
c = Circle(1.2)
a = c.area()
p = c.perimeter()
d = c.diameter()

# Test attributes of rectangle class
r = Rectangle(3, 4)
a2 = r.area()
p2 = r.perimeter()

print(a, '    ', p, '     ', d, '     ', a2, '       ', p2)

# Test attributes of complex class
# count = 0
# complex_array = []
# for i in range (100):
#     real = 10 * random.random()
#     imag = -15 * random.random()
#     check_py = (complex(real, imag))
#     check_me = (Complex(real, imag))
#     complex_array[i][0].append(real)
#     complex_array[i][1].append(imag)
#     if check_py != check_me:
#         count += 1
示例#2
0
#!/usr/bin/env python

#Author: Makenzie Brian
#Date: February 14, 2018
#Class: ME 599
#File: lab5 > testfile.py
#Description: test for classes

from complex import Complex
from shapes import Circle
from shapes import Rectangle

if __name__ == '__main__':
    a = Complex(1.0, '-2.3')
    b = Complex(2)
    c = Complex()
    d = Complex(1, -1)

    print a, b, c, d, '\n'

    c = Circle('21')
    a = c.area()
    d = c.diameter()
    p = c.perimeter()

    r = Rectangle('3', 4)
    ar = r.area()
    pr = r.perimeter()

    print a, d, p
    print ar, pr