Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter1/homework/4 #798

Open
wants to merge 36 commits into
base: Chapter1/Homework/4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
436e7c0
Initial readme.md change commit. Needs further editing.
ellmaster Jan 27, 2020
8bb15b5
Changed the README.md so it reflects the task besser.
ellmaster Jan 27, 2020
8f96b40
Fixed wrong counting
ellmaster Jan 27, 2020
e36643b
Fix to point 7 not being displayed
ellmaster Jan 27, 2020
30c5041
Merge pull request #119 from csinn/Mentor/Ellmaster/Chapter1/Homework…
Almantask Jan 28, 2020
7f1f687
Hoemwork 3 intro and task
Almantask Feb 22, 2020
ff761df
Added intro to readme
Almantask Feb 22, 2020
e74f3a7
Homework 4 sections on tests
Almantask Feb 22, 2020
225549b
Title renamed properly
Almantask Feb 23, 2020
0d0e761
Update README.md
Almantask Apr 19, 2020
270311f
Update README.md
Almantask Sep 16, 2020
1094445
Updated readme with the testing description and how to solve failing …
Almantask Sep 16, 2020
a8fdcb8
created lesson 3 class
MostafaA1s Jun 13, 2023
1747807
Done with implementing funcs and run tests
MostafaA1s Jun 13, 2023
3b2a213
More advanced tests for BMI
Almantask Jan 20, 2020
f15cbee
Invalid Bmi validation messages fixed
Almantask Jan 20, 2020
a9f75ce
Generalised console testing framework
Almantask Jan 21, 2020
2340d29
Redundant line removed from tests
Almantask Jan 21, 2020
2b3d097
Fixed console tests
Almantask Jan 21, 2020
d307919
StubConsoleOutput renamed to FakeConsoleOutput
Almantask Jan 21, 2020
6c0c463
Proper cleanup of test files with all cases
Almantask Jan 21, 2020
63a1e41
Console tests better comments and naming
Almantask Jan 21, 2020
4b10d9d
Refactored ConsoleTests
Almantask Jan 21, 2020
75d6c00
ConsoleInput better comment
Almantask Jan 21, 2020
fb47ee4
Removed the obsolete test case.
ellmaster Jan 24, 2020
919595b
Fixed tests
Almantask Jan 23, 2020
46d87b0
Homework intro
Almantask Feb 22, 2020
9bd88f9
More intro to the homework task
Almantask Feb 23, 2020
0567047
Title renamed properly
Almantask Feb 23, 2020
59a8a4f
Update README.md
Almantask Sep 16, 2020
ab5c1eb
Made tests more consistent and logical
Almantask Sep 16, 2020
57b7467
Made more sense in tests, even more consistent
Almantask Sep 16, 2020
44529bb
Updated ReadMe
Almantask Sep 16, 2020
408b7be
Update README.md
Almantask Sep 30, 2020
5a7c335
Merge branch 'Chapter1/Homework/4' of https://github.com/MostafaA1s/C…
MostafaA1s Jun 15, 2023
7519605
Finished implementing the branching using if conditions and re factor…
MostafaA1s Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Src/BootCamp.Chapter/Checks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,32 @@ public static class Checks
public static int PromptInt(string message)
{
// To do: call your implementation.
return 0;


return Lesson3.PromtInt(message);
}

public static string PromptString(string message)
{
// To do: call your implementation.
return "";


return Lesson3.PromtString(message);
}

public static float PromptFloat(string message)
{
// To do: call your implementation.
return 0;


return Lesson3.PromtFloat(message);
}

public static float CalculateBmi(float weight, float height)
{
// To do: call your implementation.
return 0;

return Lesson3.CalculatingBMI(weight, height);
}
}
}
115 changes: 115 additions & 0 deletions Src/BootCamp.Chapter/Lesson3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;

namespace BootCamp.Chapter
{
internal class Lesson3
{
public static void Demo()
{
string name, surname;
int age;
float weight, height;
int counter = 0;
while (counter < 3)
{
Console.WriteLine("Enter Name:");
name = Convert.ToString(Console.ReadLine());

Console.WriteLine("Enter SurName:");
surname = Convert.ToString(Console.ReadLine());

Console.WriteLine("Enter age:");
age = int.Parse(Console.ReadLine());

Console.WriteLine("Enter weight:");
weight = float.Parse(Console.ReadLine());

Console.WriteLine("Enter height:");
height = float.Parse(Console.ReadLine());



Console.WriteLine("{0} {1} is {2} years old his weight is {3} kg and his height is {4} cm.", name, surname, age, weight, height);

float bmi = (weight / height / height) * 10000f;
Console.WriteLine("your BMI: {0} ", bmi);




counter++;
}
}

public static float CalculatingBMI(float weight, float height)
{
if (weight <= 0 || height <= 0)
{
Console.WriteLine("Failed calculating BMI. Reason:");

if (height <= 0)
{
Console.WriteLine($"Height cannot be equal or less than zero, but was {height}.");
}
if (weight <= 0)
{
Console.WriteLine($"Weight cannot be equal or less than zero, but was {weight}.");
}

return -1;

}
float bmi = (weight / height / height);
return bmi;
}

public static int PromtInt(string msg)
{
Console.WriteLine(msg);
string input = Console.ReadLine();

bool isNum = int.TryParse(input, out int num);

if (!isNum)
{
Console.WriteLine($"\"{input}\" is not a valid number.");

return -1;
}
return num;
}

public static float PromtFloat(string msg)
{
Console.WriteLine(msg);
string input = Console.ReadLine();

bool isNum = float.TryParse(input, out float num);

if (!isNum)
{
Console.WriteLine($"\"{input}\" is not a valid number.");
return -1;
}
return num;
}
public static string PromtString(string msg)
{
Console.WriteLine(msg);
string input = Console.ReadLine();

if (String.IsNullOrEmpty(input))
{
Console.WriteLine("Name cannot be empty.");
return "-";
}
return input;
}



}
}
1 change: 1 addition & 0 deletions Src/BootCamp.Chapter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Program
{
static void Main(string[] args)
{
Lesson3.Demo();
}
}
}
Binary file added docs/images/Failed-Tests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/TestsWindow.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.