+ 1

Learning Necessities - Classes

So, would this be good enough knowledge of classes or should I leanrn more aboout it? Are these the methods classes mainly use and as a result I'm good on classes, I can move on? P.S. this is just so I'm prepared for college and I don't get even more stressed, Also covid is making me do this :/ idm tho its's fun. import datetime from itertools import count class Beginner_Pokemon(): Level = 5 _ids = count(0) def __init__(self,name,move_1,move_2): self.name = name self.move_1 = move_1 self.move_2 = move_2 #self.Moves = f'Move 1: {self.move_1} \nMove 2: {self.move_2}' self.id = next(self._ids) @property def Moves(self): return f'Move 1: {self.move_1} \nMove 2: {self.move_2}' @Moves.setter def Moves(self,new): move_1, move_2 = new.split(' ') self.move_1 = move_1 self.move_2 = move_2 @Moves.deleter def Moves(self): self.move_1 = None self.move_2 = None @classmethod def Pick_Level(cls,New_Level): cls.Level = New_Level @staticmethod def Time(): print(datetime.datetime.today()) def __repr__(self): return f"Beginner_Pokemon('{self.name}','{self.move_1}','{self.move_2}')" def __str__(self): return f"-Beginner Pokemon- \n{self.name} \nMove 1: {self.move_1} \nMove 2 {self.move_2}" class Sinnoh(Beginner_Pokemon): Nation = 'Sinnoh' def __init__(self,name,move_1,move_2,origin): super().__init__(name,move_1,move_2) self.origin = origin def __repr__(self): return f"Sinnoh('{self.name}','{self.move_1}','{self.move_2},'{self.origin}'' - Sinnoh(Beginner_Pokemon)" def __str__(self): return f"Name: {self.name} \nMove_1: {self.move_1} \nMove_2: {self.move_2} \nOrigin: {Sinnoh.Nation}: {self.origin}" Piplup = Sinnoh('Piplup','Pound','Leer','Oak Town') Chimchar = Sinnoh('Chimchar','Scratch','Leer','Twinleaf Town') Snivy = Beginner_Poke

13th Jul 2020, 12:10 AM
Prog
Prog - avatar
4 Respostas
+ 1
Ha kind of copied the counter thing but thanks anyway XD
13th Jul 2020, 12:53 AM
Prog
Prog - avatar
0
you know if youre comfortable with classes or not. if you gotta ask though you probably arent. Keep practicing
13th Jul 2020, 12:44 AM
Slick
Slick - avatar
0
Ye I'm comfortable with them but just asking to see if there's any important stuff I didn't find on my own research that would be pretty important for classes. Hoping more advanced programmers could answer it so there's less gaps in my learning.
13th Jul 2020, 12:47 AM
Prog
Prog - avatar
0
well you didnt copy and paste the code so you have an idea of how it works. so just keep using what you learned until it is second nature and you dont need to think about it too much. make projects and try creating classes built off existing classes. Basically just keep coding
13th Jul 2020, 12:52 AM
Slick
Slick - avatar