Challenge: 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:
TitleandAuthor. - The default constructor must set both
TitleandAuthorfields to"Unknown". - The parameterized constructor must accept two string parameters and assign them to the
TitleandAuthorfields, respectively. - Creating a
Bookwithout parameters must initialize it with"Unknown"values. - Creating a
Bookwith parameters must initialize it with the provided values.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 2
single
Fråga AI
Fråga AI
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?
Fantastiskt!
Completion betyg förbättrat till 4.17
Challenge: 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:
TitleandAuthor. - The default constructor must set both
TitleandAuthorfields to"Unknown". - The parameterized constructor must accept two string parameters and assign them to the
TitleandAuthorfields, respectively. - Creating a
Bookwithout parameters must initialize it with"Unknown"values. - Creating a
Bookwith parameters must initialize it with the provided values.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 2
single