Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Create a Book Class | Constructors and Overloading
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# OOP Class Construction Drills

bookChallenge: Create a Book Class

Opgave

Swipe to start coding

Practice creating a class with both a default and a parameterized constructor. Your goal is to implement a Book class that can be initialized with or without specifying the title and author.

  • The class must have two public string fields: Title and Author.
  • The default constructor must set both Title and Author fields to "Unknown".
  • The parameterized constructor must accept two string parameters and assign them to the Title and Author fields, respectively.
  • Creating a Book without parameters must initialize it with "Unknown" values.
  • Creating a Book with parameters must initialize it with the provided values.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 2
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: Create a Book Class

Stryg for at vise menuen

Opgave

Swipe to start coding

Practice creating a class with both a default and a parameterized constructor. Your goal is to implement a Book class that can be initialized with or without specifying the title and author.

  • The class must have two public string fields: Title and Author.
  • The default constructor must set both Title and Author fields to "Unknown".
  • The parameterized constructor must accept two string parameters and assign them to the Title and Author fields, respectively.
  • Creating a Book without parameters must initialize it with "Unknown" values.
  • Creating a Book with parameters must initialize it with the provided values.

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 1. Kapitel 2
single

single

some-alt