class Student:
def __init__(self, name, no, laptop):
self.name = name
self.no = no
self.laptop = laptop
class Laptop:
def __init__(self, brand, cpu, ram):
self.brand = brand
self.cpu = cpu
self.ram = ram
def AddRam(self):
self.ram += 16
s1 = Student("John Doe", 41,Student.Laptop("Asus","I7 10950H",16))
print(s1.name)
print(s1.laptop.brand, s1.laptop.cpu, s1.laptop.ram)
s1.laptop.AddRam()
print(s1.laptop.brand, s1.laptop.cpu, s1.laptop.ram)
I'm trying to understand the logic of inner classes, if the usage is not true, how should it be?
I mean, is it right way to use the laptop parameter in outer class or it should be in the inner class ?