Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

oggetto di tipo Colore

V
Virtnet (1230 points)
4 32 43
in Es2 by (1.2k points)
Ciao,

Sto ora sul test "test_20b_Skyline,"

Dal test file vedo che manda a sfondo un colore 'verde' per esempio,
Cosa io provo è, fare il 'verde'  ugale a (0,255,0), e mando questo a Colore, ma ancora non va..

Forse io faccio in un modo sbagliato
523 views

1 Answer

_andrea_ (45670 points)
11 42 297
by (45.7k points)
Quel verde se non sbaglio è un Colore creato in precedenza dal test. Che errori ti dà?
V
Virtnet (1230 points)
4 32 43
by (1.2k points)
sfondo = Colore(self.r,self.g,self.b)
AttributeError: 'Skyline' object has no attribute 'r'

Ho fatto che self.r e gli altri sono ugali a 0
Xriuk (13590 points)
6 24 116
by (13.6k points)

Tu stai creando un nuovo colore passandogli r, g e b della classe Skyline, ma non ha quelle variabili, infatti 'Skyline' object has no attribute 'r', self si riferisce alla classe nella quale lo richiami (in questo caso Skyline)

_andrea_ (45670 points)
11 42 297
by (45.7k points)
Devi fare soltanto
self.sfondo=parametroPassatoA__init__
V
Virtnet (1230 points)
4 32 43
by (1.2k points)
__init__ di Colore?
ho provato

    (col, ) = s.to_tuple()
TypeError: 'Colore' object is not iterable

se mando self.sfondo = Colore()
_andrea_ (45670 points)
11 42 297
by (45.7k points)
Scusa ma non sto capendo...
V
Virtnet (1230 points)
4 32 43
by (1.2k points)
Vorrei capire cosa significa che vuol dire "dove sfondo e' un oggetto di tipo Colore"

Perche quando faccio self.sfondo = Colore() mi ancoa da un errore
_andrea_ (45670 points)
11 42 297
by (45.7k points)
Tu dovresti avere
class Skyline:
    def __init__(self,sfondo):

Ora hai che sfondo è un oggetto di tipo colore, quindi dovrebbe bastare
self.sfondo=sfondo
Per avere un attributo sfondo nell'oggetto Skyline che corrisponde all'oggetto di tipo colore passato a __init__ col nome di sfondo
V
Virtnet (1230 points)
4 32 43
by (1.2k points)
Ho fatto cosi, ma ancora da un errore.

Ho provato fare un test da solo, per esempio :

a = Skyline('verde')
a.to_tuple()
mi da 'verde'

non capisco cosa non definito bene
L'errore essato è   

(col, ) = s.to_tuple()
TypeError: 'Colore' object is not iterable
_andrea_ (45670 points)
11 42 297
by (45.7k points)
ma tu (col,)=s.to_tuple() dove lo hai scritto?
V
Virtnet (1230 points)
4 32 43
by (1.2k points)
Questo sta nel test file.
l problema risolto ,spero :) , Grazie di nuovo Andrea