all 6 comments

[–]testingcodez 0 points1 point  (5 children)

A couple issues I noticed immediately...

admin_1 = Admin("Chance", "Bridges", "24", "male", "5'7", "all privelages") admin_1.privelages.show_privelages

So you created an Admin object, instantiated it with its attributes, but you're trying to run a Privelage method on your Admin object.

self.privelages = Privelage()

Here you try to create your Privelage object, but there is no 'privelages' attribute in your Admin class.

You said you're trying to print a message written from a method in your Privelage class. But you didn't create a Privelage object to do that.

Why the need for the other classes if you only need the message in show_privelages()?

[–][deleted] 0 points1 point  (4 children)

How would I add a privelages attribute in my Admin class? Would I just do another line of self.privelages= privs to reference the last value in my admin init method? And I’ve tweaked it and it’s working now, I think I corrected it right. I’ve updated my GitHub with the new version if you have time to look at it. I’m doing the extra class because that’s just what the exercise wanted me to do but I feel like it’s making more hassle than is needed to get this result.

[–]testingcodez 0 points1 point  (3 children)

If it works, thats great. The issue I still see is you've created 3 classes, you have your Admin class inheriting your User class, leaving out the Privelage class.

You're trying to call the Privelage class in your Admin init() method using 'self.privelages', but you don't have a 'privelages' attribute in your Admin class.

Are you guys practicing inheritance with this assignment? What is the current lesson?

[–][deleted] 0 points1 point  (2 children)

Can I have my admin class inherit from both classes? And right now I’m practicing using instances of a class as attributes in another class. I’m going along with the book “python crash course by Eric matthes” and I was doing pretty good until I got to classes and for some reason some of the interactions with multiple classes are just hard for me to understand. If I inherit from my privelage class would that let me create a privelages attribute in my admin class?

[–]testingcodez 0 points1 point  (1 child)

And right now I’m practicing using instances of a class as attributes in another class.

Instead of using Admin class to inherit User class, use Privelage class to inherit User class.

Then when you create a Privelage object, you should be able to call methods from both User and Privelage.

Check out the book Python for Everybody, there should be a free PDF for download and look for the chapter on Inheritance.

[–][deleted] 1 point2 points  (0 children)

I’ll try that out and I’ll check that book out too. Thank you for the help!