Challenge: Compose a Computer Class
Uppgift
Swipe to start coding
Practice composition by building a Computer class that contains other component classes. In this task, you will implement a Computer class that holds references to CPU, RAM, and Storage objects as its fields.
- Add fields to the
Computerclass forCPU,RAM, andStorage. - Implement a constructor for
Computerthat takesCPU,RAM, andStorageobjects as parameters and assigns them to the corresponding fields. - Add a method
GetSpecs()to theComputerclass that returns a string combining the results of callingGetInfo()on each component.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. 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
Fantastiskt!
Completion betyg förbättrat till 4.17
Challenge: Compose a Computer Class
Svep för att visa menyn
Uppgift
Swipe to start coding
Practice composition by building a Computer class that contains other component classes. In this task, you will implement a Computer class that holds references to CPU, RAM, and Storage objects as its fields.
- Add fields to the
Computerclass forCPU,RAM, andStorage. - Implement a constructor for
Computerthat takesCPU,RAM, andStorageobjects as parameters and assigns them to the corresponding fields. - Add a method
GetSpecs()to theComputerclass that returns a string combining the results of callingGetInfo()on each component.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 2
single