Challenge: Compose a Computer Class
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
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Can you explain this in simpler terms?
What are some examples related to this topic?
How does this information apply to real-world situations?
Fantastisk!
Completion rate forbedret til 4.17
Challenge: Compose a Computer Class
Stryg for at vise menuen
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
Tak for dine kommentarer!
single