static MaximumNumber DayWithMaximumPassengers(bool[,,,] passengers) { int[] passengersPerDay = new int[DAYS]; int counter = 0; int dayWithMostPassengers = 0; int maxNumOfPass = 0; MaximumNumber max = new MaximumNumber(); for (int day = 0; day < DAYS; day++) { for (int train = 0; train < TRAINS_PER_DAY; train++) { for (int car = 0; car < CARS; car++) { for (int seat = 0; seat < SEATS; seat++) { if (passengers[day, train, car, seat] == true) { counter++; } } } } passengersPerDay[day] = counter; counter = 0; max = FindMaxNumber(passengersPerDay); dayWithMostPassengers = max.number; maxNumOfPass = max.maximumPassengers; } return(max); }
static void ShowDayWithMaxPass() { Console.WriteLine("Day with maximum number of passengers:"); MaximumNumber max = DayWithMaximumPassengers(passengers); Console.WriteLine(max.number + ": " + max.maximumPassengers); }
public void CheckSecondString_WhenGreater_RetrunStrawberry() { string max = "Strawberry"; string Result = MaximumNumber <string> .StringMaximumNumber("Apple", "Strawberry", "Peach"); Assert.AreEqual(max, Result); }
static int DailyTrainWithMaximumPassengers(bool[,,,] passengers, int day) { int[] passengersPerTrain = new int[TRAINS_PER_DAY]; int counter = 0; int trainWithMostPassengers = 0; int maxNumOfPass = 0; MaximumNumber max = new MaximumNumber(); for (int train = 0; train < TRAINS_PER_DAY; train++) { for (int car = 0; car < CARS; car++) { for (int seat = 0; seat < SEATS; seat++) { if (passengers[day, train, car, seat] == true) { counter++; } } } passengersPerTrain[train] = counter; counter = 0; max = FindMaxNumber(passengersPerTrain); trainWithMostPassengers = max.number; maxNumOfPass = max.maximumPassengers; } Console.WriteLine("Maximum number of passengers is {0} in the train # {1}", maxNumOfPass, trainWithMostPassengers); return(trainWithMostPassengers); }
public void CheckFloat_ThirdNumber_WhenGreaterNo_ThirdNumber() { double max = 30.2; double Result = MaximumNumber <double> .MaxFloatNumber(20.2, 28.1, 30.2); Assert.AreEqual(max, Result); }
public void CheckFirstString_WhenGreater_ReturnPeach() { string max = "Peach"; string Result = MaximumNumber <string> .StringMaximumNumber("Peach", "Apple", "Banana"); Assert.AreEqual(max, Result); }
public void CheckFirstMaximumNumber_WhenGreaterNo_FirstPosition() { int max = 22; int Result = MaximumNumber <int> .MaxNumber(22, 11, 10); Assert.AreEqual(max, Result); }
public void CheckThirMaximumNumber_WhenGreaterNo_ThirdNumber() { int max = 28; int Result = MaximumNumber <int> .MaxNumber(22, 24, 28); Assert.AreEqual(max, Result); }
public void CheckFloat_SecondNumber_WhenGreaterNo_SecondNumber() { double max = 28.1; double Result = MaximumNumber <double> .MaxFloatNumber(20.2, 28.1, 11.2); Assert.AreEqual(max, Result); }
static MaximumNumber DayWithMaximumPassengers(List <List <List <List <bool> > > > passengers) { int[] passengersPerDay = new int[DAYS]; int counter = 0; int dayWithMostPassengers = 0; int maxNumOfPass = 0; MaximumNumber max = new MaximumNumber(); for (int day = 0; day < DAYS; day++) { for (int train = 0; train < TRAINS_PER_DAY; train++) { for (int car = 0; car < CARS; car++) { for (int seat = 0; seat < SEATS; seat++) { if (passengers[day] [train] [car] [seat] == true) { counter++; Console.WriteLine("{0} {1} {2} {3} -- {4}", day, train, car, seat, counter); } } } } Console.WriteLine("{0} - {1}", day, counter); passengersPerDay[day] = counter; counter = 0; max = FindMaxNumber(passengersPerDay); dayWithMostPassengers = max.trainNumber; maxNumOfPass = max.maximumPassengers; } return(max); }
static int CarWithMaximumPassengers(bool[,,,] passengers, int day, int train) { int[] passengersPerCar = new int[CARS]; int counter = 0; int carWithMostPassengers = 0; int maxNumOfPass = 0; MaximumNumber max = new MaximumNumber(); for (int car = 0; car < CARS; car++) { for (int seat = 0; seat < SEATS; seat++) { if (passengers[day, train, car, seat] == true) { counter++; } } passengersPerCar[car] = counter; counter = 0; max = FindMaxNumber(passengersPerCar); carWithMostPassengers = max.number; maxNumOfPass = max.maximumPassengers; } Console.WriteLine("Maximum number of passengers is {0} in the car # {1}", maxNumOfPass, carWithMostPassengers); return(carWithMostPassengers); }
public void CheckSecondMaximumNumber_WhenGreaterNo_SecondNumber() { int max = 24; int Result = MaximumNumber <int> .MaxNumber(22, 24, 10); Assert.AreEqual(max, Result); }
//Act public void Given_MaxNumberAt2ndPosition_WhenChecked_ThenReturn_SameNumber() { int expectedResult = 55; int result = MaximumNumber.MaximumIntegerNumber(10, 22, 55); //Assert Assert.AreEqual(expectedResult, result); }
public void GivenIntegerArray_Should_Return_LargestInteger() { int[] values = { 89, 8, 99, 18, 2 }; MaximumNumber <int> maximumNumber = new MaximumNumber <int>(values); int max = maximumNumber.GetMaximumValue(); Assert.AreEqual(99, max); }
public void GivenFloatArray_Should_Return_LargestFloat() { double[] values = { 0.77, 0.6, 1.3, 32.233, 3.122 }; MaximumNumber <double> maximumNumber = new MaximumNumber <double>(values); double max = maximumNumber.GetMaximumValue(); Assert.AreEqual(32.233, max); }
public void GivenStringArray_Should_Return_LargestString() { string[] values = { "lion", "cat", "dog", "elephant", "rat" }; MaximumNumber <string> maximumNumber = new MaximumNumber <string>(values); string max = maximumNumber.GetMaximumValue(); Assert.AreEqual("rat", max); }
public void GivenDoubleArray_Should_Return_LargestDouble() { double[] values = { 10.6, 25.9, 8.2, 9.56, 20.8, 6.9, 21.5 }; MaximumNumber <double> maximumNumber = new MaximumNumber <double>(values); double max = maximumNumber.GetMaximum(); Assert.AreEqual(25.9, max); }
public void GivenStringArray_Should_Return_LargestString() { string[] values = { "222", "498", "999", "333", "777", "888" }; MaximumNumber <string> maximumNumber = new MaximumNumber <string>(values); string max = maximumNumber.GetMaximum(); Assert.AreEqual("999", max); }
public void GivenIntegerArray_Should_Return_LargestInteger() { int[] values = { 3, 6, 7, 10, 4, 8 }; MaximumNumber <int> maximumNumber = new MaximumNumber <int>(values); int max = maximumNumber.GetMaximum(); Assert.AreEqual(10, max); }
public void MaxInteger_At3rd_Position() { //AAA //Arrange int[] array = new int[] { 5, 20, 100 }; //Act int result = MaximumNumber <int> .MaxNum(array); //Assert Assert.AreEqual(100, result); }
public void MaxDouble_At3rd_Position() { //AAA //Arrange double[] array = { 50.2, 200.25, 1011.1235 }; //Act double result = MaximumNumber <double> .MaxNum(array); //Assert Assert.AreEqual(1011.1235, result); }
public void MaxString_At1st_Position() { //AAA //Arrange string[] array = { "11", "10", "1" }; //Act string result = MaximumNumber <string> .MaxNum(array); //Assert Assert.AreEqual("11", result); }
public void MaxInteger_At1st_Position() { //AAA //Arrange //MaximumNumber<int> maximum = new MaximumNumber<int>(); int[] array = new int[] { 5, 2, 1 }; //Act int result = MaximumNumber <int> .MaxNum(array); //Assert Assert.AreEqual(5, result); }
static MaximumNumber FindMaxNumber(int[] passengers) { MaximumNumber max = new MaximumNumber(); int maxNumOfPass = 0; int currentMax = 0; int itemWithMaximumPass = 0; for (int i = 0; i < passengers.Length; i++) { currentMax = passengers[i]; if (currentMax > maxNumOfPass) { maxNumOfPass = currentMax; itemWithMaximumPass = i; } } max.maximumPassengers = maxNumOfPass; max.trainNumber = itemWithMaximumPass; return(max); }
public void GivenMaxIntegerAtThirdPosition_WhenCheck_ShouldReurnMaximumInteger() { MaximumNumber <int> maxInteger = new MaximumNumber <int>(3, 2, 4); Assert.AreEqual(maxInteger.maxMethod(), 4); }
public void GivenMaxIntegerAtSecondPosition_WhenCheck_ShouldReurnMaximumInteger() { MaximumNumber <int> maxInteger = new MaximumNumber <int>(4, 6, 3); Assert.AreEqual(maxInteger.maxMethod(), 6); }
public void GivenMaxFloat_WhenCheck_ShouldReurnMaximumFloatValue() { MaximumNumber <float> maxInteger = new MaximumNumber <float>(4.4f, 2.4f, 3.6f); Assert.AreEqual(maxInteger.maxMethod(), 4.4f); }
public void GivenMaxString_WhenCheck_ShouldReurnMaximumStringValue() { MaximumNumber <string> maxInteger = new MaximumNumber <string>("Apple", "Peach", "Banana"); Assert.AreEqual(maxInteger.maxMethod(), "Peach"); }
/// <summary> /// Constructor /// </summary> public MaximumNumberTest() { _algorithm = new MaximumNumber(); }