

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















Abs (away from) Trahere (to draw) Abstraction
"Relevant" to what?
Interfaces
public interface IPrintable { void Print(); } public interface IPrintable { public abstract void Print(); } compiler Keyword Name
public interface IDrawable { void Draw(); } public class Circle : IDrawable { // TODO: Add fields and a constructor public void Draw() { // TODO: implement } } public class Rectangle : IDrawable { // TODO: Add fields and a constructor public void Draw() { // TODO: implement } }
public void Draw() { DrawLine(this.width, '', ''); for (int i = 1; i < this.height - 1; ++i) DrawLine(this.width, '', ' '); DrawLine(this.width, '', '*'); } private void DrawLine(int width, char end, char mid) { Console.Write(end); for (int i = 1; i < width - 1; ++i) Console.Write(mid); Console.WriteLine(end); }
Polys (many) Morphe (shape/forms) Polymorphos
public static void Main() { static int MyMethod(int a, int b) {} static double MyMethod(double a, double b) { โฆ } } Method overloading
MathOperation +Add(int, int): int +Add(double, double, double): double +Add(decimal, decimal, decimal): decimal MathOperations mo = new MathOperations(); Console.WriteLine(mo.Add(2, 3)); Console.WriteLine(mo.Add(2.2, 3.3, 5.5)); Console.WriteLine(mo.Add(2.2m, 3.3m, 4.4m));