Top Banner
Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave
10

Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

Modellering af iTunes

Oplæg til næste uges øvelses- og afleveringsopgave

Page 2: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 2

iTunes

Track

Playlist

Search field

Page 3: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 3

iTunes Class Model

Track

timenameartistalbumratingplaycountlastPlayeddateAddedreleaseDate...

void add(Track t)void remove(Track t)

List<Track> search(String s)

void shuffle()void sort(...)

void burnToDisc()...

Playlist

*

add(Playlist p)remove(Playlist p)

void import(...)void export(...)

...

Player

*

*Associations

Page 4: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 4

The Association Pattern

A B*

class A { ... // A-attributter public A() { ...

}

... // A-metoder

}

class B { ...}

import java.util.*;

bs = new ArrayList<B>();

private List<B> bs;

public void add(B b) { bs.add(b); } public void remove(B b) { bs.remove(b); }

Page 5: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 5

iTunes Class Model

Track

timenameartistalbumratingplaycountlastPlayeddateAddedreleaseDate...

void add(Track t)void remove(Track t)

List<Track> search(String s)

void shuffle()void sort(...)

void burnToDisc()...

Playlist

*

Page 6: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 6

Find a Best Rated Trackclass Playlist { private String name; private List<Track> tracks; ... /** = a best rated track from the playlist * pre: the playlist is not empty */ public Track findABestRated() { Track res= tracks.get(0); for (Track t: tracks) { if ( t.getRating() > res.getRating() ) { res= t; } } return res; }}

Page 7: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 7

Find All Tracks By Artistclass Playlist { private String name; private List<Track> tracks; ... /** = all tracks in the playlist by the theArtist */ public List<Track> findAllBy(String theArtist) { List<Track> res= new ArrayList<Track>(); for (Track t: tracks) { if ( t.getArtist().contains(theArtist) ) { res.add(t); } } return res; }}

Page 8: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 8

Find All Tracks That Matchclass Playlist { private String name; private List<Track> tracks; ... /** = all tracks in the playlist matching s */ public List<Track> findAllMatching(String s) { List<Track> res= new ArrayList<Track>(); for (Track t: tracks) { if ( t.getName().contains(s) || t.getArtist().contains(s) || ... ) { res.add(t); } } return res; }}

t.contains

(s) Track

timenameartistalbumratingplaycountlastPlayeddateAddedreleaseDate...

Page 9: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 9

Associations All Over...

Inbox * Email

Playlist * Track

Track * Picture

Calendar * Appointment

DNA register * DNA string

DNA string * AminoAcidResidue

RabbitHuntWorld * Item (Animal or Vegetation)

GreenfootWorld * Actor

Presentation * Slide

Slide * SlideObjects

Animation * Picture

...

Page 10: Modellering af iTunes Oplæg til næste uges øvelses- og afleveringsopgave.

dIntProg, E08 10

Nifty!