✅ 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
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.
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
/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
how are you building it? have you saved your latest edits?
yes
because, as said, it builds fine with the code you shared.
i need to submit it and then i can check
hmm
weird
okay thanks tho
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
iircthis is made by my school
the program itself
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
okay
!close
Closed!