Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Static vs Instance Demo | Static Classes and Members
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# OOP Class Construction Drills

bookChallenge: 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 TotalVehicles to track the total number of vehicles created.
  • Define two public instance fields: Make and Model.
  • Implement a constructor that takes two parameters: make and model.
  • In the constructor, assign the make parameter to the Make field and the model parameter to the Model field.
  • Each time the constructor is called, increment the TotalVehicles static field by one.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: 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 TotalVehicles to track the total number of vehicles created.
  • Define two public instance fields: Make and Model.
  • Implement a constructor that takes two parameters: make and model.
  • In the constructor, assign the make parameter to the Make field and the model parameter to the Model field.
  • Each time the constructor is called, increment the TotalVehicles static field by one.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6
single

single

some-alt