C
C#2w ago
Waluigi

Class trouble

I'm currently learning how to work with classes for Object Oriented Programming, and for some reason, I am getting this error for creating a smartphone and laptop despite having declared them in the classes part.
No description
No description
No description
No description
No description
No description
23 Replies
FusedQyou
FusedQyou2w ago
Error is pretty clear, no? The required parameter brand is not set. You only set the model
Waluigi
WaluigiOP2w ago
hm?
FusedQyou
FusedQyou2w ago
hmmmmm?
SG97
SG972w ago
assuming textBox1.Text is the model
Waluigi
WaluigiOP2w ago
textbox 1 is supposed to be where the user inputs the brand and the mod, am I supposed to have 2 textboxes or something?
FusedQyou
FusedQyou2w ago
Ah okay, this was info I didn't know about So how is this done then? How does a user input both? Two textboxes sound better here unless you want the headache of figuring out which part is which
Waluigi
WaluigiOP2w ago
if you want i can screenshot the whole thing?
FusedQyou
FusedQyou2w ago
It would help if you just $paste the code
MODiX
MODiX2w ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
FusedQyou
FusedQyou2w ago
Anyway the thing here is that textBox1.Text occupies the first parameter and the second paramete ris left unset. You need to consider how you pass the second parameter.
Waluigi
WaluigiOP2w ago
BlazeBin - hlydggpzcukl
A tool for sharing your source code with the world!
Waluigi
WaluigiOP2w ago
It's starting to make sense, but I'm still lost... sorry...
FusedQyou
FusedQyou2w ago
You probably just want a second text box, the same way you made the first one
Waluigi
WaluigiOP2w ago
oh ok thanks!
Waluigi
WaluigiOP2w ago
I think I'm doing it wrong
No description
SG97
SG972w ago
what parameters does a Smartphone need
Waluigi
WaluigiOP2w ago
just the model and the brand
SG97
SG972w ago
exactly
Waluigi
WaluigiOP2w ago
same for the laptop
SG97
SG972w ago
now, you only provide one and thus VS is giving you an error
OlujA
OlujA2w ago
Let's say you get Model from textBox1.Text and Brand from textBox2.Text, in this case your code should look like this;
CS
myElectronic = new SmartPhone(textBox1.Text, textBox2.Text);
CS
myElectronic = new SmartPhone(textBox1.Text, textBox2.Text);
Waluigi
WaluigiOP2w ago
oh, thanks! yep everything works now thanks for the help!
OlujA
OlujA2w ago
Np, theese are basic things about classes, highly recommend watching a >5 min video to catch up, you'll understand the concept pretty quickly. Good luck

Did you find this page helpful?