Challenge: Static vs Instance Demo
Opgave
Swipe to start coding
Write the complete Vehicle class from scratch, including all required fields, the static member, and the constructor.
- Define a public static field
TotalVehiclesto track the total number of vehicles created. - Define two public instance fields:
MakeandModel. - Implement a constructor that takes two parameters:
makeandmodel. - In the constructor, assign the
makeparameter to theMakefield and themodelparameter to theModelfield. - Each time the constructor is called, increment the
TotalVehiclesstatic field by one.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 6
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Fantastisk!
Completion rate forbedret til 4.17
Challenge: Static vs Instance Demo
Stryg for at vise menuen
Opgave
Swipe to start coding
Write the complete Vehicle class from scratch, including all required fields, the static member, and the constructor.
- Define a public static field
TotalVehiclesto track the total number of vehicles created. - Define two public instance fields:
MakeandModel. - Implement a constructor that takes two parameters:
makeandmodel. - In the constructor, assign the
makeparameter to theMakefield and themodelparameter to theModelfield. - Each time the constructor is called, increment the
TotalVehiclesstatic field by one.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 3. Kapitel 6
single