/// <summary> /// Reads the color that was set for the wallet. /// </summary> /// <returns> The wallet color.</returns> public static WalletColor ReadWalletColor() { WalletColor result = WalletColor.Black; string stringValue = result.ToString(); bool found = false; while (!found) { stringValue = ConsoleUtil.ReadAlphabeticValue("Wallet Color"); stringValue = ConsoleUtil.InitialUpper(stringValue); // If a matching enumerated value can be found... if (Enum.TryParse <WalletColor>(stringValue, out result)) { found = true; } else { Console.WriteLine("Invalid wallet color."); } } return(result); }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The color of the wallet.</param> public Wallet(WalletColor color) { this.color = color; // Creates a new money pocket for the wallet. this.moneyPocket = new MoneyPocket(); }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The color of the wallet.</param> public Wallet(WalletColor color) { this.moneyPocket = new MoneyPocket(); // Plug the handleBalanceChange method into the OnBalanceChange. this.moneyPocket.OnBalanceChange += this.HandleBalanceChange; }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The color of the wallet.</param> /// <param name="moneyPocket">The wallet's money pocket.</param> public Wallet(WalletColor color, IMoneyCollector moneyPocket) { this.color = color; this.moneyPocket = moneyPocket; this.moneyPocket.OnBalanceChange = () => { this.OnBalanceChange?.Invoke(); }; }
/// <summary> /// Initializes a new instance of the Guest class. /// </summary> /// <param name="name">The name of the guest.</param> /// <param name="age">The age of the guest.</param> /// <param name="moneyBalance">The initial amount of money to put into the guest's wallet.</param> /// <param name="Color">The color of the guest's wallet.</param> public Guest(string name, int age, decimal moneyBalance, WalletColor Color, Gender gender, IMoneyCollector checkingAccount) { this.checkingAccount = checkingAccount; //this.checkingAccount.AddMoney(2500.00m); this.age = age; this.bag = new List <Item>(); this.name = name; this.wallet = new Wallet(Color); this.wallet.AddMoney(moneyBalance); }
public WalletModel(string name, WalletType type, bool @default, double balance, List <DateOffsetBalance> dateOffsetBalance, WalletColor color, DateTime lastUpdated) { Name = name; Type = type; Default = @default; Balance = balance; DateOffsetBalance = dateOffsetBalance; Color = color; LastUpdated = lastUpdated; }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The color of the wallet.</param> /// <param name="moneyPocket">The wallet's money pocket.</param> public Wallet(WalletColor color, IMoneyCollector moneyPocket) { this.color = color; this.moneyPocket = moneyPocket; this.moneyPocket.OnBalanceChange = () => { if (this.OnBalanceChange != null) { this.OnBalanceChange(); } }; }
/// <summary> /// Initializes a new instance of the Guest class. /// </summary> /// <param name="name">The name of the guest.</param> /// <param name="age">The age of the guest.</param> /// <param name="moneyBalance">The initial amount of money to put into the guest's wallet.</param> /// <param name="Color">The color of the guest's wallet.</param> public Guest(string name, int age, decimal moneyBalance, WalletColor Color, Gender gender, IMoneyCollector checkingAccount) { this.adpotedAnimal = this.AdoptedAnimal; this.age = age; this.bag = new List <Item>(); this.checkingAccount = checkingAccount; this.name = name; this.wallet = new Wallet(Color); this.wallet.AddMoney(moneyBalance); // Set the x and y axis positions. this.YPosition = 0; this.XPosition = 0; }
/// <summary> /// Initializes a new instance of the Guest class. /// </summary> /// <param name="name">The name of the guest.</param> /// <param name="age">The age of the guest.</param> /// <param name="walletColor">The color of the guest's wallet.</param> /// <param name="moneyBalance">The money balance of the guest's wallet.</param> /// <param name="gender">The gender of the guest.</param> /// <param name="checkingAccount">The account for collecting money.</param> public Guest(string name, int age, WalletColor walletColor, decimal moneyBalance, Gender gender, IMoneyCollector checkingAccount) { this.age = age; this.checkingAccount = checkingAccount; this.checkingAccount.OnBalanceChange += this.HandleBalanceChange; this.gender = gender; this.name = name; this.CreateTimers(); this.wallet = new Wallet(walletColor, new MoneyPocket()); this.wallet.AddMoney(moneyBalance); this.wallet.OnBalanceChange += this.HandleBalanceChange; this.XPosition = 0; this.YPosition = 0; }
/// <summary> /// Initializes a new instance of the Guest class. /// </summary> /// <param name="name">The name of the guest.</param> /// <param name="age">The age of the guest.</param> /// <param name="moneyBalance">The initial amount of money to put into the guest's wallet.</param> /// <param name="walletColor">The color of the guest's wallet.</param> /// <param name="gender">The guest's gender.</param> /// <param name="checkingAccount">The guest's checking account.</param> public Guest(string name, int age, decimal moneyBalance, WalletColor walletColor, Gender gender, IMoneyCollector checkingAccount) { this.age = age; this.name = name; this.wallet = new Wallet(walletColor); this.wallet.AddMoney(moneyBalance); this.gender = gender; this.checkingAccount = checkingAccount; // Creates the bag of items. this.bag = new List <Item>(); // Initialize positions. this.XDirection = 0; this.YPosition = 0; }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The color of the wallet.</param> public Wallet(WalletColor color) { this.moneyPocket = new MoneyPocket(); }
/// <summary> /// Adds a guest to the zoo. /// </summary> /// <param name="zoo">The zoo in which to add a guest.</param> private static void AddGuest(Zoo zoo) { // Create a new guest. Guest guest = new Guest("Joe", 36, 0, WalletColor.Brown, Gender.Male, new Account()); // Prompt for guest name. bool nameSuccess = false; while (!nameSuccess) { try { string guestName = ConsoleUtil.ReadAlphabeticValue("Name"); guest.Name = ConsoleUtil.InitialUpper(guestName); nameSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // prompt for guest gender. bool genderSuccess = false; while (!genderSuccess) { try { guest.Gender = ConsoleUtil.ReadGender(); genderSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // Prompt for guest age. bool ageSuccess = false; while (!ageSuccess) { try { guest.Age = ConsoleUtil.ReadIntValue("Age"); ageSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // Prompt for guest wallet money balance. bool walletSuccess = false; // CREATED DECIMAL METHOD IN UTIL. while (!walletSuccess) { try { guest.Wallet.AddMoney(ConsoleUtil.ReadDecimalValue("Wallet Money Balance")); walletSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // Prompt for guest wallet color. bool walletColorSuccess = false; while (!walletColorSuccess) { try { WalletColor walletColor = ConsoleUtil.ReadWalletColor(); walletColorSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // Prompt for guest checking account balance. bool accountSuccess = false; while (!accountSuccess) { try { guest.CheckingAccount.AddMoney(ConsoleUtil.ReadDecimalValue("Account Balance")); accountSuccess = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } // Add the newly created guest to the list after selling them a ticket and a waterbottle. This will subtract $18.00 from the entered money balance. zoo.AddGuest(guest, zoo.SellTicket(guest)); // Show the new animal. ShowGuest(zoo, guest.Name); }
/// <summary> /// Initializes a new instance of the Wallet class. /// </summary> /// <param name="color">The wallet's color.</param> /// <param name="moneyBalance">The wallet's money balance.</param> public Wallet(WalletColor color, decimal moneyBalance) { this.color = color; this.moneyPocket = new MoneyCollector(moneyBalance); }
/// <summary> /// Actions for the wallet color combo box in the guest window. /// </summary> /// <param name="sender">System data.</param> /// <param name="e">Associated event data.</param> private void walletColorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { WalletColor walletColor = (WalletColor)this.walletColorComboBox.SelectedItem; }