Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Create a Book Class | Constructors and Overloading
C# OOP Class Construction Drills

bookChallenge: Create a Book Class

Uppgift

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 allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 2
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

bookChallenge: Create a Book Class

Svep för att visa menyn

Uppgift

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 desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 2
single

single

some-alt