Ejemplo n.º 1
0
        public void onAddClicked(IBeer beer)
        {
            IBeer newBeer = Dao.getData().GetNewBeer();

            AssignValuesToBeer(newBeer, beer);
            Dao.getData().AddNewBeer(newBeer);
            Beers.Add(newBeer);
        }
Ejemplo n.º 2
0
 public IBeerRank CreateBeerRank(decimal overallScore,
                                 decimal tasteScore,
                                 decimal lookScore,
                                 decimal smellScore,
                                 IBeer beer,
                                 decimal compositeScore,
                                 int totalReviews)
 {
     return(new BeerRank(overallScore, tasteScore, lookScore, smellScore, beer, compositeScore, totalReviews));
 }
Ejemplo n.º 3
0
 private static void printAllBeers(List <IBeer> beers)
 {
     for (int i = 0; i < beers.Count; i++)
     {
         IBeer beer = beers[i];
         Console.WriteLine($"Bear number {i + 1}:");
         Console.WriteLine($"{beer.Speciality} {beer.Race}\nProducent: {beer.Producent.Name}\n{beer.AlcoholPercent}% of alcohol\nDensity of wort (BLG): {beer.BLG}\nBiterness in IBU scale: {beer.IBU}\nHue in EBC scale: {beer.EBC}\nBest drink in temperature: {beer.ServingTemperature}C and to: {beer.BestBefore}\nSea story: {beer.SeaStory}\nIngredients: {beer.Ingredients}");
         Console.WriteLine($"Cheers!");
         Console.WriteLine($"-------------------");
     }
 }
Ejemplo n.º 4
0
 private void AssignValuesToBeer(IBeer newBeer, IBeer beer)
 {
     newBeer.Race               = beer.Race;
     newBeer.Speciality         = beer.Speciality;
     newBeer.Producent          = beer.Producent;
     newBeer.AlcoholPercent     = beer.AlcoholPercent;
     newBeer.IBU                = beer.IBU;
     newBeer.EBC                = beer.EBC;
     newBeer.ServingTemperature = beer.ServingTemperature;
     newBeer.BLG                = beer.BLG;
     newBeer.BestBefore         = beer.BestBefore;
     newBeer.SeaStory           = beer.SeaStory;
     newBeer.Ingredients        = beer.Ingredients;
 }
        public override IBeerRank GetBeerRank(IEnumerable <IBeerReview> reviews, IBeer beer)
        {
            if (reviews == null)
            {
                throw new ArgumentNullException(nameof(reviews));
            }

            if (beer == null)
            {
                throw new ArgumentNullException(nameof(beer));
            }

            var beerReviews  = reviews as IBeerReview[] ?? reviews.ToArray();
            var reviewsCount = beerReviews.Length;

            if (reviewsCount == 0)
            {
                throw new ArgumentException("Reviews cannot be empty!");
            }

            decimal aggregateScore = beerReviews.Sum(beerReview =>
                                                     (decimal)(OverallScoreMultiplier * beerReview.Overall
                                                               + beerReview.Look
                                                               + beerReview.Smell
                                                               + beerReview.Taste)
                                                     / (OverallScoreMultiplier + 3));

            var overallAverage = GetAverageScore(beerReviews, r => r.Overall);
            var tasteAverage   = GetAverageScore(beerReviews, r => r.Taste);
            var smellAverage   = GetAverageScore(beerReviews, r => r.Smell);
            var lookverage     = GetAverageScore(beerReviews, r => r.Look);

            var finalScore = aggregateScore / reviewsCount;
            var rank       = this.Factory.CreateBeerRank(overallAverage,
                                                         tasteAverage,
                                                         lookverage,
                                                         smellAverage,
                                                         beer,
                                                         finalScore,
                                                         reviewsCount);

            return(rank);
        }
Ejemplo n.º 6
0
        public BeerRank(decimal overallScore,
                        decimal tasteScore,
                        decimal lookScore,
                        decimal smellScore,
                        IBeer beer,
                        decimal compositeScore,
                        int totalReviews)
        {
            if (beer == null)
            {
                throw new ArgumentNullException(nameof(beer));
            }

            this.OverallScore   = Math.Round(overallScore, 2);
            this.TasteScore     = Math.Round(tasteScore, 2);
            this.LookScore      = Math.Round(lookScore, 2);
            this.SmellScore     = Math.Round(smellScore, 2);
            this.Beer           = beer;
            this.CompositeScore = Math.Round(compositeScore, 2);
            this.TotalReviews   = totalReviews;
        }
 public abstract IBeerRank GetBeerRank(IEnumerable <IBeerReview> reviews, IBeer beer);
Ejemplo n.º 8
0
 public BeerProxy(Person person)
 {
     _person   = person;
     _realBeer = new Beer();
 }
Ejemplo n.º 9
0
 public void AddNewBeer(IBeer beer)
 {
     beers.Add(beer);
 }
 public void Fill(IBeer beer)
 {
     drink = beer.Pour();
 }
Ejemplo n.º 11
0
 public void Add(IBeer beer)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 12
0
 public void AddNewBeer(IBeer beer)
 {
     //adding beer to database
     //    beers.Add(beer);
 }
Ejemplo n.º 13
0
 public Beer(IBeer beers) => _beers = beers;
Ejemplo n.º 14
0
 public EditedBeer(IBeer beer)
 {
     _beer = beer;
 }