From the course: Programming Foundations: Object-Oriented Design

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Jukebox class diagrams

Solution: Jukebox class diagrams - Python Tutorial

From the course: Programming Foundations: Object-Oriented Design

Start my 1-month free trial

Solution: Jukebox class diagrams

- Let's take a look at our solution and how we converted our conceptual model into a class diagram for a spaceship jukebox. There wasn't an obvious place to start here so we arbitrarily decided to begin with the song class because, well, songs are pretty essential to a jukebox. In regards to attributes, at a minimum, each song should have a title, so the user knows which song they're choosing and it should have an artist because one of our requirements was being able to sort songs by artist. Both of those attributes could be represented as strings and we decided to keep them private to the class. That means we should include a public get method for other objects to retrieve the song's title and artist. Finally, the song isn't very useful if it can't be played. So, we included a play method. Now, how that song actually gets played, is it on a record, a cd, an mp3 stored in a database? It doesn't matter here, they will all get handled under the hood in the implementation of the song…

Contents