Challenge: Static vs Instance Demo
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 6
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Mahtavaa!
Completion arvosana parantunut arvoon 4.17
Challenge: Static vs Instance Demo
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 6
single