Skip to content

Instantly share code, notes, and snippets.

@mlevkovsky
Created July 20, 2019 21:29
Show Gist options
  • Save mlevkovsky/4811ec0255783cda2e7fe9cd0c82d9ba to your computer and use it in GitHub Desktop.
Save mlevkovsky/4811ec0255783cda2e7fe9cd0c82d9ba to your computer and use it in GitHub Desktop.
switch default clause
import { Track } from "../models/Track";
export class BackgroundImage {
dimension: string;
url: string;
}
export class BackgroundImageService {
getBackgroundArt(track: Track): BackgroundImage {
switch(track.getGenre()) {
default:
return null;
case "hiphop":
const hipHopImage: BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/Qcl98B8Bk3I'};
return hipHopImage;
case "jazz":
const jazzImage : BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/dBWvUqBoOU8'};
return jazzImage;
case "rap":
const rapImage : BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/auq_QbyIA34'};
return rapImage;
case "country":
const countryImage: BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/RnFgs90NEHY'};
return countryImage;
}
}
}
getBackgroundArt(track: Track): BackgroundImage {
switch(track.getGenre()) {
case "hiphop":
const hipHopImage: BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/Qcl98B8Bk3I'};
return hipHopImage;
case "jazz":
const jazzImage : BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/dBWvUqBoOU8'};
return jazzImage;
case "rap":
const rapImage : BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/auq_QbyIA34'};
return rapImage;
case "country":
const countryImage: BackgroundImage = {dimension: 'small', 'url': 'https://unsplash.com/photos/RnFgs90NEHY'};
return countryImage;
default:
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment