static void Main(string[] args) { //Opdracht1 //Track t1 = new Track(1, "Nelly Furtado - ", "Maneater"); //t1.AlbumSource = "Loose"; //t1.Length = new Time(4, 31); //t1.Style = Category.Pop; //Console.WriteLine(t1.DisplayName); //Console.WriteLine(t1.DisplayLength); //Console.WriteLine("Album: {0}", t1.AlbumSource); //Console.WriteLine("Tijd in seconden: {0}", t1.GetLengthInSeconds()); //Console.WriteLine("Category: {0}", t1.Style.ToString()); //Console.ReadLine(); //Opdracht2 //Track t1 = new Track(1, "Prince", "Guitar"); //t1.Length = new Time(4, 12); //Track t2 = new Track(2, "Nelly Furtado", "Say it Right"); //t2.Length = new Time(4, 41); //Track t3 = new Track(3, "David Guetta & Chris Willis", "Love is gone"); //t3.Length = new Time(3, 50); //TrackList trackList = new TrackList(); //trackList.Add(t1); //trackList.Add(t2); //trackList.Add(t3); //Console.WriteLine("Aantal tracks: {0}", trackList.Count); //trackList.Remove(t3); //Console.WriteLine("Aantal tracks: {0}", trackList.Count); //trackList.Add(t3); //Console.WriteLine("Totale tijd tracklist: {0}", trackList.TotalTime); //Console.WriteLine(); //Console.WriteLine("Random lijst:"); //List<Track> shuffled = trackList.Shuffle(); //foreach (Track t in shuffled) // Console.WriteLine(t.Id + " " + t.DisplayName); //Console.ReadLine(); //Opdracht3 //MemoRecorder memo = new MemoRecorder(1000); //memo.MaxCartridgeType = MemoCartridgeType.C90; //memo.Make = "Sony"; //memo.Model = "FE190"; //memo.PriceExBtw = 129.95M; //memo.CreationDate = DateTime.Now.AddMonths(-6); //Console.WriteLine(memo.DisplayIdentity(true, true)); //Console.WriteLine(memo.DisplayStorageCapacity()); //Console.WriteLine("Consumer price: {0:f2}", memo.ConsumerPrice); //Console.WriteLine(memo.GetDeviceLifeTime()); //Console.ReadLine(); //Opdracht5 //CdDiscMan discman = new CdDiscMan(1000); //discman.Make = "JVC"; //discman.Model = "HG-410"; //discman.PriceExBtw = 149.00M; //discman.DisplayWidth = 320; //discman.DisplayHeight = 160; //discman.CreationDate = DateTime.Parse("12-2-2006"); //Console.WriteLine(discman.DisplayIdentity(true, true)); //Console.WriteLine("Opslag capacity {0}", discman.DisplayStorageCapacity()); //Console.WriteLine("Display resolution {0} pixels", discman.TotalPixels); //Console.WriteLine(discman.GetResolutionInfo()); //Console.WriteLine("Consumer price: {0:f2}", discman.ConsumerPrice); //Console.WriteLine(discman.GetDeviceLifeTime()); //Console.WriteLine("Eject status: {0}", discman.IsEjected); //discman.Eject(); //Console.WriteLine("Eject status: {0}", discman.IsEjected); //Console.ReadLine(); //Opdracht6 Mp3Player player = new Mp3Player(1000); player.Make = "Creative"; player.Model = "Alpha"; player.PriceExBtw = 99.00M; player.DisplayWidth = 120; player.DisplayHeight = 80; player.CreationDate = DateTime.Parse("1-1-2007"); player.MbSize = 1024; Track t1 = new Track(1, "Prince", "Guitar"); t1.Length = new Time(4, 12); Track t2 = new Track(2, "Nelly Furtado", "Say it Right"); t2.Length = new Time(4, 41); Track t3 = new Track(3, "David Guetta & Chris Willis", "Love is gone"); t3.Length = new Time(3, 50); TrackList trackList = new TrackList(); trackList.Add(t1); trackList.Add(t2); trackList.Add(t3); player.AddTrackList(trackList); Console.WriteLine(player.DisplayIdentity(true, true)); Console.WriteLine("Capacity {0}", player.DisplayStorageCapacity()); Console.WriteLine("Display resolution {0} pixels", player.TotalPixels); Console.WriteLine("Consumer price: {0:f2}", player.ConsumerPrice); Console.WriteLine(player.GetDeviceLifeTime()); if (player.HasTracks()) { Console.WriteLine("\nThe TrackList of this player has {0} tracks\n", trackList.Count); foreach (Track t in trackList.GetAllTracks()) Console.WriteLine(t.DisplayName); player.RemoveTrackList(); Console.WriteLine("\nThe TrackList of this player has now {0} tracks", player.TrackList.Count); } Console.ReadLine(); }
public TrackList GetShuffledList() { TrackList randomList = new TrackList(); TrackList tempList = new TrackList(); Random random = new Random(); foreach (Track t in this) { tempList.Add(t); } for (int i = tempList.Count; i > 0; i--) //Er word een temploist aangemaakt en die word dan omgegooit. Er word een random nummer uitgehaald, en dan weer op een random plek toegevoegd. Zodat het geshuffeld word. { int index = random.Next(i); randomList.Add(tempList[index]); tempList.RemoveAt(index); } return(randomList); }
public TrackList GetShuffledList() { Random shuffel = new Random(); TrackList copy = new TrackList(); TrackList shuffeldList = new TrackList(); foreach(Track element in this.List) { copy.Add(element); } while (copy.Count > 0) { int random = shuffel.Next(0, copy.Count - 1); shuffeldList.Add(copy[random]); copy.Remove(copy[random]); } return shuffeldList; }
static void Main(string[] args) { Track t1 = new Track(1, "Prince", "Guitar"); t1.Length = new Time(4, 12); Track t2 = new Track(2, "Nelly Furtado", "Say it Right"); t2.Length = new Time(4, 41); Track t3 = new Track(3, "David Guetta & Chris Willis", "Love is gone"); t3.Length = new Time(3, 50); TrackList trackList = new TrackList(); trackList.Add(t1); trackList.Add(t2); trackList.Add(t3); Console.WriteLine("Aantal tracks: {0}", trackList.Count); trackList.Remove(t3); Console.WriteLine("Aantal tracks: {0}", trackList.Count); trackList.Add(t3); Console.WriteLine("Totale tijd tracklist: {0}", trackList.TotalTime.ToString()); Console.WriteLine(); Console.WriteLine("Random lijst:"); List <Track> shuffled = trackList.GetShuffledList(); foreach (Track t in shuffled) { Console.WriteLine(t.Id + " " + t.DisplayName); } Console.ReadLine(); MemoRecorder memo = new MemoRecorder(1000); memo.MaxCartridgeType = MemoCartridgeType.C90; memo.Make = "Sony"; memo.Model = "FE190"; memo.PriceExBtw = 129.95M; memo.CreationDate = DateTime.Now.AddMonths(-6); Console.WriteLine(memo.DisplayIdentity(true, true)); Console.WriteLine(memo.DisplayStorageCapacity()); Console.WriteLine("Consumer price: {0:f2}", memo.ConsumerPrice); Console.WriteLine(memo.GetDeviceLifeTime()); Console.ReadLine(); CdDiscMan discman = new CdDiscMan(1000); discman.Make = "JVC"; discman.Model = "HG-410"; discman.PriceExBtw = 149.00M; discman.DisplayWidth = 320; discman.DisplayHeight = 160; discman.CreationDate = DateTime.Parse("12-2-2006"); Console.WriteLine(discman.DisplayIdentity(true, true)); Console.WriteLine("Opslag capacity {0}", discman.DisplayStorageCapacity()); Console.WriteLine("Display resolution {0} pixels", discman.TotalPixels); Console.WriteLine(discman.GetResolutionInfo()); Console.WriteLine("Consumer price: {0:f2}", discman.ConsumerPrice); Console.WriteLine(discman.GetDeviceLifeTime()); Console.WriteLine("Eject status: {0}", discman.IsEjected); discman.Eject(); Console.WriteLine("Eject status: {0}", discman.IsEjected); Console.ReadLine(); Mp3Player player = new Mp3Player(1000); player.Make = "Creative"; player.Model = "Alpha"; player.PriceExBtw = 99.00M; player.DisplayWidth = 120; player.DisplayHeight = 80; player.CreationDate = DateTime.Parse("1-1-2007"); player.MbSize = 1024; Track ta = new Track(1, "Prince", "Guitar"); ta.Length = new Time(4, 12); Track tb = new Track(2, "Nelly Furtado", "Say it Right"); tb.Length = new Time(4, 41); Track tc = new Track(3, "David Guetta & Chris Willis", "Love is gone"); tc.Length = new Time(3, 50); TrackList trackLista = new TrackList(); trackLista.Add(ta); trackLista.Add(tb); trackLista.Add(tc); player.AddTrackList(trackLista); Console.WriteLine(player.DisplayIdentity(true, true)); Console.WriteLine("Capacity {0}", player.DisplayStorageCapacity()); Console.WriteLine("Display resolution {0} pixels", player.TotalPixels); Console.WriteLine("Consumer price: {0:f2}", player.ConsumerPrice); Console.WriteLine(player.GetDeviceLifeTime()); if (player.HasTracks()) { Console.WriteLine("The TrackList of this player has {0} tracks", player.TrackList.Count); foreach (Track t in player.TrackList.GetAllTracks()) { Console.WriteLine(t.DisplayName); } player.RemoveTrackList(); Console.WriteLine("The TrackList of this player has now {0} tracks", player.TrackList.Count); } Console.ReadLine(); }