static HiddenBookmark MaakBookmark() { HiddenBookmark site = new HiddenBookmark(); string naam, url; Console.Write("naam: "); naam = Console.ReadLine(); site.Naam = naam; Console.Write("url: "); url = Console.ReadLine(); Console.WriteLine(""); site.URL = url; return(site); }
static void Main(string[] args) { string naam; string url; int count = 1; int clearNr; List <Bookmark> Sites = new List <Bookmark>(); HiddenBookmark [] site = new HiddenBookmark [3]; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Geef uw 3 favoriete sites:\n"); Console.ResetColor(); for (int i = 0; i < 3; i++) { site[i] = MaakBookmark(); } foreach (var item in site) { Console.WriteLine($"{count}: {item.Naam} {item.URL}"); count++; } /*Console.WriteLine("Geef het bookmarknummer dat je wil verwijderen: "); * clearNr = int.Parse(Console.ReadLine()); * site[clearNr-1].Naam=" "; * site[clearNr-1].URL = " "; * count = 0; * foreach (var item in site) * { * Console.WriteLine($"{count}: {item.Naam} {item.URL}"); * count++; * }*/ site[0].OpenSite(); }
static void Main(string[] args) { Console.WriteLine("Please enter you five favorite websites."); HiddenBookmark[] bookMarks = new HiddenBookmark[5]; // FILL ARRAY WITH USER INPUT for (int i = 0; i < bookMarks.Length; i++) { Console.WriteLine($"WEBSITE {i + 1}: "); Console.WriteLine(new string('=', 20)); HiddenBookmark bm = new HiddenBookmark(); Console.WriteLine("Name: "); bm.Name = Console.ReadLine(); Console.WriteLine("URL: "); bm.URL = Console.ReadLine(); bookMarks[i] = bm; Console.Clear(); } // OPEN CHOSEN WEBSITE int input = 0; do { // PRINT ARRAY for (int i = 0; i < bookMarks.Length; i++) { Console.WriteLine($"{i + 1}) {bookMarks[i].Name}: {bookMarks[i].URL}"); } Console.WriteLine("Which website do you wish to visit ?"); input = AskForInt($"1 - {bookMarks.Length}: Select Website / -1: Remove Item / 0: Change Item / 99: End Program"); // Remove bookmark if (input == -1) { int index = AskForInt($"1 - {bookMarks.Length}: which bookmark do you wish to remove?"); if (index > 0 && index <= bookMarks.Length) { bookMarks[index - 1].Name = ""; bookMarks[index - 1].URL = ""; } else { Console.WriteLine("Invalid index."); } } // Change bookmark else if (input == 0) { int index = AskForInt($"1 - {bookMarks.Length}: which bookmark do you wish to change?"); if (index > 0 && index <= bookMarks.Length) { Console.WriteLine("Name: "); bookMarks[index - 1].Name = Console.ReadLine(); Console.WriteLine("URL: "); bookMarks[index - 1].URL = Console.ReadLine(); } else { Console.WriteLine("Invalid index."); } } // Open bookmarked website else if (input > 0 && input <= bookMarks.Length) { bookMarks[input - 1].OpenSite(); } } while (input != 99); }
static void Main(string[] args) { bool running = true; Bookmark[] topFive = new Bookmark[5]; Bookmark google = new Bookmark("Google ", "www.google.com"); Bookmark youtube = new Bookmark("Youtube ", "www.youtube.com"); Bookmark facebook = new Bookmark("Facebook ", "www.facebook.com"); Bookmark reddit = new Bookmark("Reddit ", "www.reddit.com"); HiddenBookmark github = new HiddenBookmark("Github ", "www.github.com"); topFive[0] = google; topFive[1] = youtube; topFive[2] = facebook; topFive[3] = reddit; topFive[4] = github; Console.WriteLine(topFive[4].ToString()); while (running) { int index = 0; switch (SelectMenu("Bekijk top 5 bookmarks", "Bookmarks aanpassen", "Bookmarks verwijderen", "Stop")) { case 0: switch (SelectMenu(BookmarkZonderNull(topFive), "Top Five")) { case 0: topFive[0].Opensite(); break; case 1: topFive[1].Opensite(); break; case 2: topFive[2].Opensite(); break; case 3: topFive[3].Opensite(); break; case 4: topFive[4].Opensite(); break; } break; case 1: index = SelectMenu(topFive, "Welke Bookmark wil je aanpassen"); Console.Write("Geef de naam van de bookmark in: "); string naam = Console.ReadLine(); Console.WriteLine(); Console.Write("Geef de url van de bookmark in: "); string url = Console.ReadLine(); Console.WriteLine(); topFive = AanpassenBookmark(topFive, index, naam, url); break; case 2: index = SelectMenu(BookmarkZonderNull(topFive), "Bookmark Leegmaken"); topFive = VerwijderBookmark(topFive, index); Console.WriteLine($"We hebben index {index} leeg gemaakt "); Console.ReadKey(); break; case 3: running = false; break; } } Console.ReadLine(); }