proc
proc
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
o7
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Legends , thanks again for this guidance !
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Probably just because the names were the same on both sides it just looked like what the hell is this code trying to accomplish here
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Ok ok ok that makes sense........ I really don't know why that just wasn't making any sense at all
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Ok the penny might have dropped there
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
It's like passing to functions in C where it might be void dothis (int a) - but you could pass it any variable with any name, it's only called a in that function -
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Oh wait I think I might get it
58 replies
CC#
Created by proc on 8/31/2024 in #help
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
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Is "this" part of the C# language - e.g. it's not something the programmer has arbitrarily made up, it's a function or something
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
Nice so immediately that makes sense to me now, just the this.make = make etc - I can't get
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
I get that in future code, you could then put Car car1 = new Car - but why the constructor, what is that doing?
58 replies
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
i put asterisk next to the bit which to me just seems pointless and can't get my head around...... really sorry if this is a stupid question!
58 replies
CC#
Created by proc on 8/31/2024 in #help
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............
class Car
{
String make;
String model;
int year;
String color;

public Car(String make, String model, int year, String color)
{
*this.make = make;
this.model = model;
this.year = year;
this.color = color;*
}
class Car
{
String make;
String model;
int year;
String color;

public Car(String make, String model, int year, String color)
{
*this.make = make;
this.model = model;
this.year = year;
this.color = color;*
}
58 replies
CC#
Created by proc on 8/31/2024 in #help
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
CC#
Created by proc on 8/31/2024 in #help
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
CC#
Created by proc on 8/31/2024 in #help
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
CC#
Created by proc on 8/31/2024 in #help
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
CC#
Created by proc on 8/31/2024 in #help
Beginner question: classes and constructor code?
It reminds me a bit of enums from C which I also hated
58 replies