Generate an object-oriented design for a system that keeps tracks of your CD and DVD collection.
· Identify each of the classes, associated data, and operations for the classes.
· Generate the pseudocode for each of the classes as demonstrated on p. 251.
· Draw a GUI that will create the objects and provide access to each object’s processing methods. Note. Use the drawing tool in Microsoft® Word or in any other applicable drawing tool to complete this part of the assignment.
To generate an object-oriented design for a system that tracks CD and DVD collections, we would need to identify the classes, associated data, and operations for each class.
Here is an example of how this could be done:
1. Class: Collection
- Data:
- cdCollection: array of CD objects
- dvdCollection: array of DVD objects
- collectionSize: integer
- Operations:
- addCD(cd: CD): void
- removeCD(cd: CD): void
- addDVD(dvd: DVD): void
- removeDVD(dvd: DVD): void
- displayCollection(): void
2. Class: CD
- Data:
- title: string
- artist: string
- duration: float
- Operations:
- setTitle(title: string): void
- setArtist(artist: string): void
- setDuration(duration: float): void
- getTitle(): string
- getArtist(): string
- getDuration(): float
3. Class: DVD
- Data:
- title: string
- director: string
- duration: float
- Operations:
- setTitle(title: string): void
- setDirector(director: string): void
- setDuration(duration: float): void
- getTitle(): string
- getDirector(): string
- getDuration(): float
Below is an example of pseudocode for these classes:
```
Class Collection
Method addCD(cd)
cdCollection.add(cd)
collectionSize = cdCollection.size() + dvdCollection.size()
End Method
Method removeCD(cd)
cdCollection.remove(cd)
collectionSize = cdCollection.size() + dvdCollection.size()
End Method
Method addDVD(dvd)
dvdCollection.add(dvd)
collectionSize = cdCollection.size() + dvdCollection.size()
End Method
Method removeDVD(dvd)
dvdCollection.remove(dvd)
collectionSize = cdCollection.size() + dvdCollection.size()
End Method
Method displayCollection()
For each cd in cdCollection
Print("CD: " + cd.getTitle() + " by " + cd.getArtist() + " (" + cd.getDuration() + " minutes)")
End For
For each dvd in dvdCollection
Print("DVD: " + dvd.getTitle() + " directed by " + dvd.getDirector() + " (" + dvd.getDuration() + " minutes)")
End For
End Method
End Class
Class CD
Method setTitle(title)
this.title = title
End Method
Method setArtist(artist)
this.artist = artist
End Method
Method setDuration(duration)
this.duration = duration
End Method
Method getTitle()
return this.title
End Method
Method getArtist()
return this.artist
End Method
Method getDuration()
return this.duration
End Method
End Class
Class DVD
Method setTitle(title)
this.title = title
End Method
Method setDirector(director)
this.director = director
End Method
Method setDuration(duration)
this.duration = duration
End Method
Method getTitle()
return this.title
End Method
Method getDirector()
return this.director
End Method
Method getDuration()
return this.duration
End Method
End Class
```
For the GUI, you can use any drawing tool to create a user interface that allows you to create objects (CDs and DVDs) and access their processing methods (such as adding/removing CDs/DVDs and displaying the collection). Use your preferred drawing tool to design the GUI layout that suits your needs.