Search the Community
Showing results for tags 'oop'.
-
Cel mai bun tutorial pe care l-am citit so far. Give it a try: Spolier: So Everything Has A Class? class Customer(object): """A customer of ABC Bank with a checking account. Customers have the following properties: Attributes: name: A string representing the customer's name. balance: A float tracking the current balance of the customer's account. """ def __init__(self, name, balance=0.0): """Return a Customer object whose name is *name* and starting balance is *balance*.""" self.name = name self.balance = balance def withdraw(self, amount): """Return the balance remaining after withdrawing *amount* dollars.""" if amount > self.balance: raise RuntimeError('Amount greater than available balance.') self.balance -= amount return self.balance def deposit(self, amount): """Return the balance remaining after depositing *amount* dollars.""" self.balance += amount return self.balance
-
Ma joc de ceva vreme cu php. Fac fel si fel de lucruri, le modific, incerc alte metode, functii, incerc sa gandesc problema din perspective diferite si evident ma blochez. Am facut un script php, upload file, incerc sa abordez stilul oop, nu stiu cat de bine imi iasa, ce gresesc si ce fac bine, anyway, m-am blocat la ceva mediocru si nu inteleg ce gresesc. Deci: index.php upload.php check.php edit: m-am grabit sa postez si am uitat sa specific unde m-am blocat , so, am 2 clase, una uploadeaza fisierul, alta verifica fisierul sa fie in anumiti parametri, e ceva simplu, extensia si marimea fisierului. Logica mea a fost: Clasa UploadFile este mostenita de CheckFile, deci apelez clasa CheckFile, fac verificarea fisierelor IF size true -> next -> IF extension true -> upload. Dar nu imi iasa nici cum, atat am invartit lucrurile incat am lasat-o balta. Nu luati in seama comentariile idioate din script, le folosesc sa ma ghidez ..