Static Hazard's Profile
Reputation: 0 Apprentice
- Active Posts:
- 50 (0.03 per day)
- 25-November 09
- Profile Views:
- Last Active:
- Oct 08 2013 05:00 PM
- Dream Kudos:
Posts I've Made
Posted 16 Apr 2013
rep.addProject(Fruit(1, 45, 3))
rep.addProject(Project(1, 45, 3))
I understand that, but I think that this line needs to be adjusted, right?
Also, I just tried that and I'm still getting the "undefined variable error" for Project. ????
Posted 16 Apr 2013Fruit is supposed to be Project. I modified an old question...sorry
Posted 16 Apr 2013There's nothing wrong with doing currentFruit.getType() exactly like you did. If you're encountering problems with that code, please tell us what those problems are.
Do I need to set currentFruit as a fruit object somehow?
When you call the addFruit method, you need to pass in a Fruit object as the argument. Other than that there's nothing special you need to do to make Python aware that currentFruit is supposed to be a Fruit object.
How can I differentiate between a variable and an object though? I think my problem currently is that the addFruit(currentFruit) method thinks that currentFruit is a variable, and not an object
Posted 28 Feb 2013You need to pass an instance of Fruit to an instance of FruitBasket.
MyApple = Fruit("Apple",1,"Red") MyBasket = FruitBasket() MyBasket.addFruit(MyApple)
My problem with this (let's say I'm running this code in FruitBasket.py), is Eclipse says that Fruit (on the first line) is an undefined variable, even though I want it to be an object.
Posted 28 Feb 2013That makes perfect sense. I was getting a non-default argument error from my code, and now I know why. Thanks!
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
Static Hazard hasn't added any friends yet.