Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02._07._2019
- {
- class Program
- {
- interface IFishSorter
- {
- double CalculateTotalKg(List<Catch> catchList);
- List<Catch> CreateNewCatchList(List<Catch> catchList);
- }
- class Catch
- {
- public double TotalKg { get; private set; }
- public int Quality { get; private set; }
- public String Species { get; private set; }
- public Catch(double totalKg, int quality, String species)
- {
- TotalKg = totalKg; Quality = quality; Species = species;
- }
- }
- class TopFishSorter : IFishSorter
- {
- public String Species { get; set; }
- public double MinQuality { get; set; }
- public double CalculateTotalKg(List<Catch> catchList) {
- double mass = 0;
- for (int i = 0; i < catchList.Count(); i++)
- {
- if (catchList[i].Quality > MinQuality)
- {
- mass += catchList[i].TotalKg;
- }
- }
- return mass;
- }
- public List<Catch> CreateNewCatchList(List<Catch> catchList) {
- List<Catch> newCatchList = new List<Catch>();
- for (int i = 0; i < catchList.Count(); i++)
- {
- if (catchList[i].Species == Species && catchList[i].Quality >= MinQuality)
- {
- newCatchList.Add(catchList[i]);
- }
- }
- return newCatchList;
- }
- }
- void RemoveCatch(List<Catch> Catch, double quality, double mass)
- {
- for (int i = 0; i < Catch.Count(); i++)
- {
- if (Catch[i].Quality < quality || Catch[i].TotalKg < mass)
- {
- Catch.RemoveAt(i);
- }
- }
- }
- static void Main(string[] args)
- {
- List<Catch> fishies = fishingBoat.PullNets();
- int total = fishies.Count();
- RemoveCatch(fishies);
- int newTotal = fishies.Count();
- if ((total - newTotal) > total / 2)
- {
- Console.Write("Boljeg ulova ima vise od pola.");
- }
- else
- {
- Console.WriteLine("Loseg ulova ima vise od pola.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment