proc
Beginner question: classes and constructor code?
I really appreciate the feedback and help as I am learning it just feels like something isn't clicking with that - so you said it's assigning the class's fields, to the arguments passed to the constructor ...........let me just churn that through my thick skull for a sec...........
58 replies
Beginner question: classes and constructor code?
Your example there makes more sense to me, but this one for example (i think he's called Bro Code on Youtube) he puts this code snippet. So the class part I completely understand what he is doing, and why - but the constructor part, is the brackets after "public Car (" arguments being passed to this constructor? And why does it have to be this.make = make; - etc - that part just seems pointless to me............
58 replies
Beginner question: classes and constructor code?
Thanks for this - it's this part I couldn't understand what was happening:
Name = name;
Birthday = birthday;
ShoeSize = shoeSize;
To me it seemed redundant so I didn't know what the point of this was...
58 replies
Beginner question: classes and constructor code?
For me it makes it appear very long-winded and of no purpose, as in the examples they are using you could probably create the same output with only a few lines of code (e.g. not even declaring a class, and only declaring variables by themselves). Is it meant to be for much larger programs that this becomes useful? Or is it really that tedious all the time?
58 replies
Beginner question: classes and constructor code?
Really useful feedback all - thanks for this, makes a lot of sense now. One thing I don't now understand, having read onwards a bit and also watched a few videos on the same topic - is the constructors. I don't see what the purpose is of declaring a new class with a few variables in it, then directly below is creating a constructor which is the same name, and then each individual variable with this.name = name, this.value = value, etc etc. All videos explain that this is necessary but doesn't really explain why they are doing it in the first place...
58 replies
Beginner question: classes and constructor code?
I just found a really useful Youtube vid actually, it seems like classes are basically for times when an object requires more complexity than just 1 value, such as an employee, like employee ID, name, date of birth, etc - so that makes more sense now to me. Would appreciate any further input still if there's anything I should know...
58 replies