Challenge: Static vs Instance Demo
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 6
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Suggested prompts:
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Génial!
Completion taux amélioré à 4.17
Challenge: Static vs Instance Demo
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 3. Chapitre 6
single