def __init__(self): self.sharpieSet = [] sharpie_1 = Sharpie("Yellow", 5.0, 19) sharpie_2 = Sharpie("Yellow", 5.0, 13) sharpie_3 = Sharpie("Yellow", 5.0, 0) self.sharpieSet.append(sharpie_1) self.sharpieSet.append(sharpie_2) self.sharpieSet.append(sharpie_3)
def test_sharpie(self): sharpie = Sharpie('blue', 10.0, 100.0) ink_amount1 = 20.0 ink_amount2 = 20 ink_amount3 = 'ink' ink_amount4 = 'True' self.assertEqual(sharpie.use(ink_amount1), 80.0) self.assertEqual(sharpie.use(ink_amount2), 60.0) self.assertEqual(sharpie.use(ink_amount3), None) self.assertEqual(sharpie.use(ink_amount4), None)
class Test_sharpie(unittest.TestCase): def setUp(self): self.sharpie = Sharpie("green", 3, 200) def test_color_of_sharpie(self): self.assertEqual(self.sharpie.color, "green") def test_width_of_sharpie(self): self.assertEqual(self.sharpie.width, float(3)) def test_ink_amount_of_sharpie(self): self.assertEqual(self.sharpie.ink_amount, float(200)) def test_use(self): self.sharpie.use() self.assertEqual(self.sharpie.ink_amount, float(199))
from sharpie import Sharpie red_sharpie = Sharpie("red", 1.3) red_sharpie.use() print(red_sharpie.get_ink()) print(red_sharpie.get_color()) red_sharpie.set_color("green") print(red_sharpie.get_color())
from sharpie import Sharpie from sharpie_set import SharpieSet s1 = Sharpie('zold', 3) s2 = Sharpie('kek', 0.5) s3 = Sharpie('barack', 2) sharpie_set = SharpieSet() sharpie_set.add(s1) sharpie_set.add(s2) sharpie_set.add(s3) s3.ink_level = 0 print(sharpie_set.count_usable()) sharpie_set.remove_trash() print(sharpie_set.sharpies)
from sharpie import Sharpie from sharpie_set import SharpieSet sharpie_set = SharpieSet() zold_sharpie = Sharpie('zöld', 1) kek_sharpie = Sharpie('kék', 2) piros_sharpie = Sharpie('piros', 4) rozsaszin_sharpie = Sharpie('rózsaszín', 5) sharpie_set.add(zold_sharpie) sharpie_set.add(kek_sharpie) sharpie_set.add(piros_sharpie) sharpie_set.add(rozsaszin_sharpie) #print(sharpie_set.count_usable()) zold_sharpie.use() kek_sharpie.use() piros_sharpie.use() rozsaszin_sharpie.use() # print(zold_sharpie.tinta_mennyiseg) # print(kek_sharpie.tinta_mennyiseg) # print(piros_sharpie.tinta_mennyiseg) # print(rozsaszin_sharpie.tinta_mennyiseg) kek_sharpie.tinta_mennyiseg = 1 piros_sharpie.tinta_mennyiseg = 1 kek_sharpie.use()
import unittest from sharpie import Sharpie sharpie = Sharpie("red", 27) class Sharpie_Test(unittest.TestCase): def test_use(self): sharpie.use() self.assertEqual(sharpie.ink_amount, 2) if __name__ == "__main__": unittest.main()
from sharpie import Sharpie import unittest my_dog = Sharpie('yellow', 10) class SharpieTest(unittest.TestCase): def test_sharpe_use(self): my_dog.use() self.assertEqual(my_dog.ink_amount, 98.5) if __name__ == '__main__': unittest.main()
from sharpie_set import Sharpie_set from sharpie import Sharpie green = Sharpie("green", 0.1) red = Sharpie("red", 0.2) orange = Sharpie("orange", 0.3) new_set = Sharpie_set() green.use() new_set.add(green) new_set.add(red) new_set.add(orange) print(new_set.count_usable())
def __init__(self): self.sharpies = [ Sharpie('red', 0.3, 88), Sharpie('brown', 0.4, 0), Sharpie('yellow', 0.5, 11) ]
def __init__(self): self.sharpie = [Sharpie("blue", 1.1), Sharpie("yellow", 1.4)]
def test_use(self): test_use = Sharpie('color', 1) self.assertEqual(test_use.use(), Sharpie('color', 1).ink_amount - 0.5)
from sharpie import Sharpie from sharpieSet import SharpieSet tolltarto = SharpieSet() print(tolltarto.sharpies) # példányosítunk 2 filcet: sarga = Sharpie('sárga', 4.5) kek = Sharpie('kék', 2) # hozzáadjuk a tolltartohoz tolltarto.add(sarga) tolltarto.add(kek) print(tolltarto.sharpies) # a sárgát használjuk 100-szor, kiürül for _ in range(100): sarga.use() print('hasznalhato filcek: ' + str(tolltarto.count_usable())) tolltarto.remove_trash() # már csak a kék van a tolltartóban: for sharpie in tolltarto.sharpies: print(sharpie.szin)
def setUp(self): self.sharpie = Sharpie("green", 3, 200)