Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions Boolean.CSharp.Main/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Car(string Make)
}
*/

Car car = new Car("Volkswagen");
Car car = new Car("Volkswagen", "Beetle");
/* When the car in instantiated, the constructor is passed a string
in this case Volkswagen which is a Make of car is passed in.
Within the constructor the 'string Make' variable has scope within the constructor and assiged to the _make member now visible to the whole class
Expand Down Expand Up @@ -108,7 +108,7 @@ public Unicycle Question4()

//TIP see we already have an internal member for the unicyclist name: _nameOfUnicyclist so you can use this to store the name internally
// it is good practice to name internal class variable with an _ at the beginning
Unicycle unicycle = new Unicycle();
Unicycle unicycle = new Unicycle("Snorre");



Expand All @@ -132,10 +132,10 @@ What are the parameters and types?
*/
Aeroplane plane = new Aeroplane();
plane.FlightDetails("LHR", "JFK");

//TODO: 5. Call the FlightDetails method that sets the cancelled message and cancel the flight

//write code here
plane.FlightDetails("The plane is cancelled.");
//write code here

return plane;
}
Expand Down
49 changes: 44 additions & 5 deletions Boolean.CSharp.Main/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,62 @@
namespace Boolean.CSharp.Main
{
public class Extension
{
{

//Implement the following methods:

//TODO: 1. add, which accepts two floats and returns a float (both floats added together)

public float add(float numOne, float numTwo) { return numOne + numTwo; }
//TODO: 2. add, which accepts two doubles and returns a double (both doubles added together)

public double add(double numOne, double numTwo) { return numOne + numTwo; }
//TODO: 3. subtract, which accepts two floats and returns a float (first float minus second float)
public float subtract(float numOne, float numTwo) { return numOne - numTwo; }

//TODO: 4. subtract, which accepts a String and a char and returns a string with all instances of the provided char removed
public string subtract(string str, char c)
{
string result = "";
foreach (char ch in str)
{
if (ch != c)
{
result += ch;
}
}
return result;
}

//TODO: 5. multiply, which accepts two ints and returns an int (first int multiplied by second int)
public int multiply(int numOne, int numTwo) { return numOne*numTwo; }

//TODO: 6. multiply, which accepts a string and an int, and returns a string containing the provided string as many times as the provided int separated by a comma. E.g. multiply("Hello", 3) -> "Hello,Hello,Hello"

//TODO: 7. multiply, which accepts an array of Strings that each contain a number, and an int. The method should return an array of ints that contain the value of multiplying each String number by the provided int E.g. multiply(["2", "7", "3"], 3) -> [6, 21, 9]
public string multiply(string str, int num)
{
string result = "";
for (int i = 0; i < num; i++)
{
if(i != 0)
{
result += "," + str;
}
else
{
result += str;
}

}
return result;
}

//TODO: 7. multiply, which accepts an array of Strings that each contain a number, and an int. The method should return an array of ints that contain the value of multiplying each String number by the provided int E.g. multiply(["2", "7", "3"], 3) -> [6, 21, 9]
public int[] multiply(string[] collection, int num)
{
int[] result = new int[collection.Length];
for (int i = 0;i < collection.Length; i++)
{
result[i] = multiply(int.Parse(collection[i]), num);
}
return result;
}
}
}
14 changes: 13 additions & 1 deletion Boolean.CSharp.Main/Misc/Bicycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ namespace Boolean.CSharp.Main.Misc
{
public class Bicycle
{
public Bicycle()
{
_wheelCount = 2;
}
public Bicycle(int wheelcount)
{
_wheelCount = wheelcount;
}
private int _wheelCount;

public int WheelCount { get; set; }
public int WheelCount
{
get => _wheelCount;
set => _wheelCount = value;
}
}
}
5 changes: 5 additions & 0 deletions Boolean.CSharp.Main/Misc/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public Car(string Make)
_make = Make;
_model = string.Empty;
}
public Car(string Make, string Model)
{
_make = Make;
_model = Model;
}

public string Make
{
Expand Down
1 change: 1 addition & 0 deletions Boolean.CSharp.Main/Misc/Motorbike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public Motorbike()

public Motorbike(string Make, string Model)
{
_cc = 373;
_make = Make;
_model = Model;
}
Expand Down
10 changes: 10 additions & 0 deletions Boolean.CSharp.Main/Misc/Unicycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ public class Unicycle
{
private string _nameOfUnicyclist;

public Unicycle()
{
_nameOfUnicyclist = string.Empty;
}

public Unicycle(string nameOfUnicyclist)
{
_nameOfUnicyclist = nameOfUnicyclist;
}

public string NameOfUnicyclist { get => _nameOfUnicyclist; set => _nameOfUnicyclist = value; }
public int WheelCount { get; set; } = 1;
}
Expand Down
Loading