Created
July 20, 2019 21:29
-
-
Save mlevkovsky/4811ec0255783cda2e7fe9cd0c82d9ba to your computer and use it in GitHub Desktop.
switch default clause
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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