Skip to content

Instantly share code, notes, and snippets.

@angusbarnes
Last active May 6, 2018 08:39
Show Gist options
  • Save angusbarnes/2e391ff8ce10b6e02f3fadb82be82e49 to your computer and use it in GitHub Desktop.
Save angusbarnes/2e391ff8ce10b6e02f3fadb82be82e49 to your computer and use it in GitHub Desktop.
All the code from lesson 1.5
using System;
class MainClass {
public static void Main ()
{
float answer = Maths.Divide(2f, 4f);
int answer2 = Maths.Addition(5, 6);
float somefloat = Maths.pi;
Console.Write(answer2);
Console.ReadKey();
Coord2 playerCoord = new Coord2(2f, 6f) + new Coord2(23f, 6f);
}
}
static class Maths {
public static float pi = 3.1415896335f;
public static float Divide(float num1, float num2)
{
float result = num1 / num2;
return result;
}
public static int Addition(int num1, int num2)
{
int result = num1 + num2;
return result;
}
}
class Cat {
public string name = "fluffy";
public string FurCol = "pink";
public int age = 1;
public int x = 2;
public void DoSomething()
{
if (age == x) {
//be happy
}
}
}
struct Coord2 {
public float x;
public float y;
//Constructor
public Coord2(float _x, float _y)
{
this.x = _x;
this.y = _y;
}
public static Coord2 operator+ (Coord2 a, Coord2 b)
{
return new Coord2(a.x + b.x, a.y + b.y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment