C
C#9mo ago
Raf Camora

✅ I dont understand this error in my code

error CS7036: There is no argument given that corresponds to the required formal parameter 'year' of 'HarleyDavidson.HarleyDavidson(string, string, int)'
12 Replies
Raf Camora
Raf CamoraOP9mo ago
https://paste.pythondiscord.com/27SA https://paste.pythondiscord.com/EPBA https://paste.pythondiscord.com/F3OA https://paste.pythondiscord.com/ADUQ Learning goals: derived classes can be derived from Create two classes: Cruiser: derived from Motorcycle. It has one additional field named SeatHeight, which is passed as the fourth parameter to the constructor. Method Ride returns the same as its base class, plus (depending on the seat height): with a seat height of 64 cm; HarleyDavidson: derived from Cruiser. Its SeatHeight is always 68 centimeters. Method Ride returns the same as its base class, plus: and with pride. Note: mind the spaces before with and and.
Pobiega
Pobiega9mo ago
that seems to be a ghost error ie, there is no actual error, your IDE is just showing an old error it builds fine for me, and I just copypasted your classes with 0 edits
Raf Camora
Raf CamoraOP9mo ago
/home/codegrade/student/Files/Program.cs(9,17): error CS7036: There is no argument given that corresponds to the required formal parameter 'year' of 'HarleyDavidson.HarleyDavidson(string, string, int)' [/home/codegrade/student/Files/Files.csproj] it still says this
Pobiega
Pobiega9mo ago
how are you building it? have you saved your latest edits?
Raf Camora
Raf CamoraOP9mo ago
yes
Pobiega
Pobiega9mo ago
because, as said, it builds fine with the code you shared.
Raf Camora
Raf CamoraOP9mo ago
i need to submit it and then i can check hmm weird okay thanks tho
Pobiega
Pobiega9mo ago
a few things btw m is HarleyDavidson && m is Cruiser is literally the same as m is HarleyDavidson since HarleyDavidson is a subclass of Cruiser, an object can never ever be a Harley and NOT be a cruiser another thing: you dont need to use {0} etc in your strings Console.WriteLine($"{m.Model} {m.Make} is also a Motorcycle and a Cruiser"); $"" is like pythons f-strings iirc
Raf Camora
Raf CamoraOP9mo ago
this is made by my school the program itself
Pobiega
Pobiega9mo ago
okay your teacher should be fired 😛 your fields should be properties dont skip bracers on if-statements, especially not multiline bodies use string interpolation over format strings
Raf Camora
Raf CamoraOP9mo ago
okay !close
Accord
Accord9mo ago
Closed!
Want results from more Discord servers?
Add your server