Exemplo n.º 1
0
 public void RemoveACanOf(Flavor flavorName) {
     Debug.WriteLine($"CanRack.RemoveACanOf was called for flavor {flavorName}.");
     Bin bin;
     if (Bins.TryGetValue(flavorName, out bin)) {
         bin.RemoveCan();
     }
 }
Exemplo n.º 2
0
 public void EmptyTheCanRackOf(Flavor flavorName) {
     Debug.WriteLine($"CanRack.EmptyTheCanRackOf was called for flavor {flavorName}.");
     Bin bin;
     if (Bins.TryGetValue(flavorName, out bin)) {
         bin.EmptyBin();
     }
 }
Exemplo n.º 3
0
 public void FillOneCanRack(Flavor OneFlavor)
 {
     Debug.WriteLine("Filling the can rack");
     {
         rack[OneFlavor] = BINSIZE;
     }
 }
Exemplo n.º 4
0
 public void AddACanOf(Flavor flavorName) {
     Debug.WriteLine($"CanRack.AddACanOf was called for flavor {flavorName.ToString()}.");
     Bin bin;
     if (Bins.TryGetValue(flavorName, out bin)) {
         bin.AddCan();
     } else {
         Debug.WriteLine($"unknown flavor {flavorName}");
     }
 }
Exemplo n.º 5
0
 public bool IsFull(Flavor flavorName) {
     Debug.WriteLine($"CanRack.IsFull was called for flavor {flavorName}.");
     Bin bin;
     bool isFull = false;
     if (Bins.TryGetValue(flavorName, out bin)) {
         isFull = bin.IsFull;
     }
     return isFull;
 }
Exemplo n.º 6
0
 public bool IsEmpty(Flavor flavorName) {
     Debug.WriteLine($"CanRack.IsEmpty was called for flavor {flavorName}.");
     Bin bin;
     bool isEmpty = true;
     if (Bins.TryGetValue(flavorName, out bin)) {
         isEmpty = bin.IsEmpty;
     }
     return isEmpty;
 }
Exemplo n.º 7
0
        public CyclingMeasureMode(ushort startDelay, Flavor.Common.Data.Measure.MeasureMode.Precise cycle, Action<long[][], List<PreciseEditorData>, short?> successfulExit, int iterations, int timeLimit, PreciseEditorData checkerPeak, int checkerIndex, short? initialShift, ushort allowedShift)
            : base((s, e) => {
                var ee = (Flavor.Common.Data.Measure.MeasureMode.Precise.SuccessfulExitEventArgs)e;
                successfulExit(ee.Counts, ee.Points, ee.Shift);
            })
        {
            // TODO: checker peak received by index, after sort found by equality again
            //_cycle = new Flavor.Common.Data.Measure.MeasureMode.Precise(min, max, peaks, startDelay, stepDelay, exposition, forwardDelay, backwardDelay, graphUpdater, (ps, peds, shift) => OnSuccessfulExit(new Flavor.Common.Data.Measure.MeasureMode.Precise.SuccessfulExitEventArgs(ps, peds, shift)), initialShift, CheckShift);
            _cycle = cycle;
            _cycle.VoltageStepChangeRequested += Cycle_VoltageStepRequested;
            _cycle.Finalize += Cycle_Finalize;
            _cycle.Disable += cycle_Disable;

            this.allowedShift = allowedShift;
            stopper = new MeasureStopper(iterations, timeLimit);
            _checkerIndex = checkerIndex;
            peak = checkerPeak;
        }
Exemplo n.º 8
0
		internal Qualifier(DocumentRange location, string name, object parameter, Flavor flavors) : base(location)
		{
			this.m_name = name;
			this.m_parameter = parameter;
			this.m_flavors = flavors;
		}
Exemplo n.º 9
0
 public Boolean IsEmpty(Flavor FlavorOfBinToBeChecked)
 {
     return IsEmpty(FlavorOfBinToBeChecked.ToString());
 }
Exemplo n.º 10
0
        public Boolean IsFull(Flavor FlavorOfBinToCheck)
        {
            Debug.WriteLine("IsFull method called");

            if (rack[FlavorOfBinToCheck] == maxCans)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 11
0
 public Can(Flavor flavor) {
     Flavor = flavor;
 }
Exemplo n.º 12
0
 public ActionResult Edit(Flavor flavor)
 {
     _db.Entry(flavor).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 13
0
 static void Add( MonsterNature nature, Stat pref, Stat dim, Flavor fav, Flavor dis )
 {
     _store.Add( nature, new PreferenceEntry { PreferredStat = pref, DiminishedStat = dim, FavoriteFlavor = fav, DislikedFlavor = dis } );
 }
Exemplo n.º 14
0
 public void EmptyCanRackOf(Flavor FlavorOfBinToBeEmptied)
 {
     Debug.WriteLine("Emptying a bin of {0}", (object)FlavorOfBinToBeEmptied);
     this.rack[FlavorOfBinToBeEmptied] = 0;
 }
Exemplo n.º 15
0
 public void RemoveACanOf(Flavor FlavorOfCanToBeRemoved)
 {
     Debug.WriteLine("Removing a can of {0}", (object)FlavorOfCanToBeRemoved);
     this.rack[FlavorOfCanToBeRemoved]--;
 }
Exemplo n.º 16
0
 public void RemoveACanOf(Flavor FlavorOfCanToBeRemoved)
 {
     RemoveACanOf(FlavorOfCanToBeRemoved.ToString());
 }
Exemplo n.º 17
0
 public ActionResult Edit(Flavor flavor)
 {
     _db.Entry(flavor).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Details", new { id = flavor.FlavorId }));
 }
Exemplo n.º 18
0
 public bool IsFull(Flavor FlavorOfBinToCheck)
 {
     Debug.WriteLine("Checking whether bin of {0} is full", (object)FlavorOfBinToCheck);
     return this.rack[FlavorOfBinToCheck] > 2;
 }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            PurchasePrice sodaPrice = new PurchasePrice(0.35M);
            CanRack       sodaRack  = new CanRack();

            Console.WriteLine("Welcome to the .NET C# Soda Vending Machine");

            Boolean timeToExit = false;

            do
            {
                sodaRack.DisplayCanRack();
                Console.Write("Please insert {0:c} worth of coins: ", sodaPrice.PriceDecimal);

                decimal totalValueInserted = 0M;
                while (totalValueInserted < sodaPrice.PriceDecimal)
                {
                    // get the coin inserted
                    string coinNameInserted = Console.ReadLine().ToUpper();
                    Coin   coinInserted     = new Coin(coinNameInserted);
                    Console.WriteLine("You have inserted a {0} worth {1:c}", coinInserted, coinInserted.ValueOf);

                    // running total of the value of the coins inserted
                    totalValueInserted += coinInserted.ValueOf;
                    Console.WriteLine("Total value inserted is {0:c}", totalValueInserted);
                }

                // select a flavor of soda
                Boolean canDispensed = false;
                while (!canDispensed)
                {
                    Console.Write("What flavor would you like? : ");


                    // oooh, this looks like trouble. Why?
                    //Needs exception handling
                    Flavor flavor = new Flavor();

                    bool flavorFound = false;
                    while (flavorFound == false) //I think this will work for exception handling?
                    {
                        try
                        {
                            //ask the user for flavor
                            string flavorName = Console.ReadLine().ToUpper();

                            flavor      = FlavorOps.ToFlavor(flavorName); //If this parse is successful...
                            flavorFound = true;                           //... this WILL execute and get us out of the loop. Maybe?
                        }
                        catch (System.ArgumentException e)
                        {
                            Console.WriteLine($"{e.Message}" + " Please try again.");
                        }
                    }



                    if (!sodaRack.IsEmpty(flavor))
                    {
                        sodaRack.RemoveACanOf(flavor);
                        Console.WriteLine("Thanks, here is your can of {0}.", flavor);
                        canDispensed = true;
                    }
                    else
                    {
                        Console.WriteLine("We are out of {0}", flavor);
                    }
                }

                Console.Write("Exit the vending machine? (y/n): ");
                string response = Console.ReadLine();
                timeToExit = response.Trim().ToUpper().StartsWith("Y");
            } while (!timeToExit);
        }
Exemplo n.º 20
0
 public bool IsEmpty(Flavor FlavorOfBinToCheck)
 {
     Debug.WriteLine("Checking whether bin of {0} is empty", (object)FlavorOfBinToCheck);
     return this.rack[FlavorOfBinToCheck] < 1;
 }
        public ActionResult Edit(int id)
        {
            Flavor thisFlavor = _db.Flavors.FirstOrDefault(flavor => flavor.FlavorId == id);

            return(View(thisFlavor));
        }
Exemplo n.º 22
0
 public static FlavorModel Map(Flavor flavor) => new FlavorModel
 {
     FlavorId    = flavor.FlavorId,
     Name        = flavor.Name,
     Description = flavor.Description,
 };
Exemplo n.º 23
0
 // This method will remove a can of the specified flavor from the rack.
 public void RemoveACanOf(Flavor FlavorOfCanToBeRemoved)
 {
     Debug.WriteLine("RemoveACanOf method called");
     if (!IsEmpty(FlavorOfCanToBeRemoved))
     {
         rack[FlavorOfCanToBeRemoved] -= 1;
     }
     else
     {
         throw new Exception("Shelf is empty");
     }
 }
 public ActionResult AddFlavorType(Flavor newFlavorType)
 {
     _db.Flavors.Add(newFlavorType);
     _db.SaveChanges();
     return(RedirectToAction("Index", "Treat"));
 }
Exemplo n.º 25
0
 public RungeKuttaIntegrator(EulerState s, Flavor f)
 {
     state = new LeapFrogState(s);
     flavor = f;
 }
Exemplo n.º 26
0
 public RungeKuttaIntegrator(EulerState s, Flavor f)
 {
     state  = new LeapFrogState(s);
     flavor = f;
 }
Exemplo n.º 27
0
 public void RemoveACanOf(Flavor FlavorOfCanToBeRemoved)
 {
     RemoveACanOf(FlavorOfCanToBeRemoved.ToString());
 }
Exemplo n.º 28
0
 public List <IceCreamItem> RemoveFlavor(Flavor flavor)
 {
     return(RemoveFlavor(flavor, Capacity));
 }
Exemplo n.º 29
0
 public Bin(Flavor flavor) {
     Flavor = flavor;
 }
Exemplo n.º 30
0
 private bool CheckIfFlavorAlreadyExist(Flavor flavor)
 {
     return(db.Flavors.Any(x => x.Name == flavor.Name && x.IsDefault == true));
 }
Exemplo n.º 31
0
 public void AddACanOf(Flavor FlavorOfCanToBeAdded)
 {
     AddACanOf(FlavorOfCanToBeAdded.ToString());
 }
Exemplo n.º 32
0
 public Boolean IsFull(Flavor CanBinToCheck)
 {
     return(IsFull(CanBinToCheck.ToString()));
 }
Exemplo n.º 33
0
 public void EmptyCanRackOf(Flavor FlavorOfBinToBeEmptied)
 {
     EmptyCanRackOf(FlavorOfBinToBeEmptied.ToString());
 }
Exemplo n.º 34
0
 public Can(Flavor f)
 {
     this.flavor = f;
 }
Exemplo n.º 35
0
 public Can(Flavor AFlavor)
 {
     TheFlavor = AFlavor;
 }
Exemplo n.º 36
0
 public static string GetFlavorName(Flavor flavor) => flavor switch
 {
Exemplo n.º 37
0
        static void Main(string[] args)
        {
            PurchasePrice sodaPrice = new PurchasePrice(0.35M);
            CanRack       sodaRack  = new CanRack();
            CoinBox       changeBox = new CoinBox(new List <Coin> {
                new Coin(Coin.Denomination.QUARTER), new Coin(Coin.Denomination.DIME),
                new Coin(Coin.Denomination.NICKEL), new Coin(Coin.Denomination.QUARTER),
                new Coin(Coin.Denomination.QUARTER), new Coin(Coin.Denomination.DIME)
            });

            Console.WriteLine("Welcome to the .NET C# Soda Vending Machine");

            Boolean timeToExit = false;

            do
            {
                sodaRack.DisplayCanRack();
                Console.Write("Please insert {0:c} worth of coins: ", sodaPrice.PriceDecimal);

                decimal totalValueInserted = 0M;
                while (totalValueInserted < sodaPrice.PriceDecimal)
                {
                    // get the coin inserted
                    string coinNameInserted = Console.ReadLine().ToUpper();
                    Coin   coinInserted     = new Coin(coinNameInserted);
                    Console.WriteLine("You have inserted a {0} worth {1:c}", coinInserted, coinInserted.ValueOf);
                    changeBox.Deposit(coinInserted);

                    // running total of the value of the coins inserted
                    totalValueInserted += coinInserted.ValueOf;
                    Console.WriteLine("Total value inserted is {0:c}", totalValueInserted);
                }

                // select a flavor of soda
                Boolean canDispensed = false;
                while (!canDispensed)
                {
                    Console.Write("What flavor would you like? : ");
                    string flavorName = Console.ReadLine().ToUpper();

                    // Well, this used to be trouble.
                    Flavor flavorEnumeral = FlavorOps.ToFlavor(flavorName);

                    if (!sodaRack.IsEmpty(flavorEnumeral))
                    {
                        sodaRack.RemoveACanOf(flavorEnumeral);
                        Console.WriteLine("Thanks, here is your can of {0}.", flavorEnumeral);
                        canDispensed = true;
                    }
                    else
                    {
                        Console.WriteLine("We are out of {0}", flavorEnumeral);
                    }
                }

                Console.Write("Exit the vending machine? (y/n): ");
                string response = Console.ReadLine();
                timeToExit = response.Trim().ToUpper().StartsWith("Y");
            } while (!timeToExit);

            Console.WriteLine("Contents of Coin Box:");

            Console.WriteLine("{0}\tHalf Dollar(s)", changeBox.HalfDollarCount);
            Console.WriteLine("{0}\tQuarter(s)", changeBox.QuarterCount);
            Console.WriteLine("{0}\tDime(s)", changeBox.DimeCount);
            Console.WriteLine("{0}\tNickel(s)", changeBox.NickelCount);
            Console.WriteLine("{0}\tSlug(s)", changeBox.SlugCount);

            Console.WriteLine();
            Console.WriteLine("Total value in coin box is {0:c}", changeBox.ValueOf);
        }
Exemplo n.º 38
0
        public ActionResult Details(int id)
        {
            Flavor model = _db.Flavors.FirstOrDefault(e => e.FlavorId == id);

            return(View(model));
        }
        public async Task <IActionResult> Edit(int id)
        {
            Flavor thisFlavor = await _db.Flavors.SingleOrDefaultAsync(flavors => flavors.FlavorId == id);

            return(View(thisFlavor));
        }
Exemplo n.º 40
0
        public ActionResult Delete(int id)
        {
            Flavor thisFlavor = _db.Flavors.FirstOrDefault(x => x.FlavorId == id);

            return(View(thisFlavor));
        }
 public ActionResult Create(Flavor flavor)
 {
     _db.Flavors.Add(flavor);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 42
0
        public ActionResult Delete(int id)
        {
            Flavor flavorToDelete = _db.Flavors.FirstOrDefault(flavor => flavor.FlavorId == id);

            return(View(flavorToDelete));
        }
Exemplo n.º 43
0
 public Boolean IsEmpty(Flavor CanBinToCheck)
 {
     return IsEmpty(CanBinToCheck.ToString());
 }
Exemplo n.º 44
0
        public int this[Flavor FlavorOfBin]
        {
            get
            {
                return rack[FlavorOfBin];
            }
            set
            {
                // we could just assign a value
                // (once we verify it is not too big or too small),
                // but let's pretend that AddACanOf() and RemoveACanOf()
                // perform some kind of data tracking operation 
                // for sales statistics, or something of that sort
                if (rack[FlavorOfBin] == value)
                {
                    // do nothing
                }
                else if (rack[FlavorOfBin] < value)
                {
                    while (!IsFull(FlavorOfBin) && rack[FlavorOfBin] < value)
                    {
                        AddACanOf(FlavorOfBin);
                    }
                }
                else if (rack[FlavorOfBin] > value)
                {
                    while (!IsEmpty(FlavorOfBin) && rack[FlavorOfBin] > value)
                    {
                        RemoveACanOf(FlavorOfBin);
                    }
                }

                int sodaCansLeftOver = rack[FlavorOfBin] - value;
                if (sodaCansLeftOver == 0)
                {
                    // do nothing
                }
                else if (sodaCansLeftOver < 0)
                {
                    string pluralCan = string.Format(sodaCansLeftOver == -1 ? "" : "s");
                    string pluralWas = string.Format(sodaCansLeftOver == -1 ? "was" : "were");
                    Debug.WriteLine("{0} Bin Full. {1} can{2} of flavor {0} {3} not placed in vending machine", 
                        FlavorOfBin, -sodaCansLeftOver, pluralCan, pluralWas);
                }
                else if (sodaCansLeftOver > 0)
                {
                    string pluralCan = string.Format(sodaCansLeftOver == 1 ? "" : "s");
                    string pluralWas = string.Format(sodaCansLeftOver == 1 ? "was" : "were");
                    Debug.WriteLine("{0} Bin Empty. {1} can{2} of flavor {0} {3} not available for removal",
                        FlavorOfBin, sodaCansLeftOver, pluralCan, pluralWas);
                }
            }
        }
Exemplo n.º 45
0
        // This method adds a can of the specified flavor to the rack.
        public void AddACanOf(Flavor FlavorOfCanToBeAdded)
        {
            Debug.WriteLine("AddACanOf method called");
            if (!IsFull(FlavorOfCanToBeAdded))
            {
                rack[FlavorOfCanToBeAdded] += 1;
            }
            else
            {
                throw new Exception("Shelf is full");
            }

        }
        public ActionResult Edit(int id)
        {
            Flavor flavor = _db.Flavors.FirstOrDefault(x => x.Id == id);

            return(View(flavor));
        }
Exemplo n.º 47
0
 public void EmptyCanRackOf(Flavor FlavorOfBinToBeEmptied)
 {
     Debug.WriteLine("EmptyCanRackOf method called");
     rack[FlavorOfBinToBeEmptied] = 0;
 }
        public ActionResult Delete(int deleteID)
        {
            Flavor deletingFlavor = _dataBase.Flavors.FirstOrDefault(flavors => flavors.FlavorId == deleteID);

            return(View(deletingFlavor));
        }
Exemplo n.º 49
0
        public Boolean IsEmpty(Flavor FlavorOfBinToCheck)
        {
            Debug.WriteLine("IsEmpty method called");

            if (rack[FlavorOfBinToCheck] == 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 50
0
 public StackNode(Flavor flavor, int startIndex)
 {
     this.flavor       = flavor;
     this.startIndex   = startIndex;
     consecutiveScoops = 1;
 }
Exemplo n.º 51
0
 public Boolean IsFull(Flavor CanBinToCheck)
 {
     return IsFull(CanBinToCheck.ToString());
 }
Exemplo n.º 52
0
 /// <summary>
 /// This is tricky. Enabling AbsoluteCrosspath and RelativeCrosspath to be equal
 /// limits count of internals that still remain different.
 /// </summary>
 /// <returns></returns>
 public override Int32 GetHashCode()
 {
     //return ToAbsolutizedString().GetHashCode();
     return(Flavor.GetHashCode() + LastEntry.GetHashCode());
 }
Exemplo n.º 53
0
 public void AddACanOf(Flavor FlavorOfCanToBeAdded)
 {
     AddACanOf(FlavorOfCanToBeAdded.ToString());
 }
        public ActionResult Delete(int id)
        {
            Flavor foundAuthor = _db.Flavors.FirstOrDefault(flavor => flavor.FlavorId == id);

            return(View(foundAuthor));
        }
Exemplo n.º 55
0
 public void EmptyCanRackOf(Flavor FlavorOfBinToBeEmptied)
 {
     EmptyCanRackOf(FlavorOfBinToBeEmptied.ToString());
 }
Exemplo n.º 56
0
 public Cone(Flavor flavor)
 {
     this._flavor = flavor;
 }
 public MultiStepIntegrator(EulerState s, Flavor f)
 {
     state = new MultiStepState(s);
     flavor = f;
 }
Exemplo n.º 58
0
 public MultiStepIntegrator(EulerState s, Flavor f)
 {
     state  = new MultiStepState(s);
     flavor = f;
 }
Exemplo n.º 59
0
 public Can(Flavor AFlavor)
 {
     TheFlavor = AFlavor;
 }
Exemplo n.º 60
0
 public Boolean IsEmpty(Flavor FlavorOfBinToBeChecked)
 {
     return(IsEmpty(FlavorOfBinToBeChecked.ToString()));
 }