Esempio n. 1
0
        public static PopBand GenerateNew(BandData data)
        {
            PopBand band = new PopBand();

            band.Name       = data.Name;
            band.YearFormed = data.YearFormed;

            band.Members = data.Members;
            band.Albums  = data.Albums;

            return(band);
        }
Esempio n. 2
0
        private static void CastToGenre(ref Band band, Genre genre)
        {
            switch (genre)
            {
            // we don't check for the 'Rock' genre, because
            // 'band' is currently a 'RockBand' type when it's created

            case Genre.Pop:
                band = new PopBand();
                break;

            case Genre.Indie:
                band = new IndieBand();
                break;
            }
        }
Esempio n. 3
0
        public MainWindow()
        {
            #region JSON stuf -- @todo cleanup, later
            //bool isReal = File.Exists(@"C:\Users\David\Desktop\bands.json");

            //string json = File.ReadAllText(@"C:\Users\David\Desktop\bands.json");

            //BandDB[] jsonBands = JsonConvert.DeserializeObject<BandDB[]>(json);


            //RockBand rockBand = new RockBand(jsonBands[1]);
            //PopBand popBand = new PopBand(jsonBands[0]);
            #endregion


            #region temp stuff
            Album album1 = new Album
            {
                Name         = "first",
                YearReleased = Album.GenerateReleaseYear(),
                SalesCount   = 10000
            };
            Album[] band1Albums = new Album[] { album1, album1 };

            BandData band1Data = new BandData
            {
                Name       = "thiswon",
                YearFormed = 1984,
                Members    = new string[] { "bob", "alan" },
                Albums     = band1Albums
            };


            RockBand  band1 = RockBand.GenerateNew(band1Data);
            PopBand   band2 = PopBand.GenerateNew(band1Data);
            IndieBand band3 = IndieBand.GenerateNew(band1Data);

            PopBand   band4 = BandFactory.MakeNewBand(Genre.Pop, band1Data) as PopBand;
            RockBand  band5 = BandFactory.MakeNewBand(Genre.Rock, band1Data) as RockBand;
            IndieBand band6 = BandFactory.MakeNewBand(Genre.Indie, band1Data) as IndieBand;

            PopBand   band7 = BandFactory.MakeNewBand(Genre.Pop, band1Data) as PopBand;
            RockBand  band8 = BandFactory.MakeNewBand(Genre.Rock, band1Data) as RockBand;
            IndieBand band9 = BandFactory.MakeNewBand(Genre.Indie, band1Data) as IndieBand;
            #endregion



            Band[] bands = { band1, band2, band3, band4, band5, band6, band7, band8, band9 };

            Array.Sort(bands);



            InitializeComponent();

            //textBoxFormed.Text = json;

            listBoxBands.ItemsSource = bands;

            comboBoxGenres.ItemsSource = Enum.GetNames(typeof(Genre));
        }