def valueOf(self): total = self._cash for i in range(self._stockCount): price = stockquote.priceOf(self._stocks[i]) amount = self._shares[i] total += amount * price return total
def writeReport(self): stdio.writeln(self._name) total = self._cash for i in range(self._stockCount): amount = self._shares[i] price = stockquote.priceOf(self._stocks[i]) total += amount * price stdio.writef('%4d %4s ', amount, self._stocks[i]) stdio.writef(' %7.2f %9.2f\n', price, amount * price) stdio.writef('%21s %10.2f\n', 'Cash:', self._cash) stdio.writef('%21s %10.2f\n', 'Total:', total)