Skip to content

Commit 671ec94

Browse files
ClémentClément
authored andcommitted
Added computer example.
1 parent 4f54a18 commit 671ec94

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Computer{
2+
private string brand;
3+
public void SetBrand(string brandP){ brand = brandP; }
4+
public Computer(string bP){ SetBrand(bP); }
5+
public override string ToString(){ return $"Brand: {brand}"; }
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Laptop : Computer{
2+
public int ScreenSize{get; set;}
3+
public Laptop(int ssP, string bP):base(bP){ScreenSize = ssP;}
4+
public override string ToString(){ return base.ToString() + $"\nScreen size: {ScreenSize}\""; }
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
public class Program{
4+
public static void Main(){
5+
Computer test1 = new Computer("Framework");
6+
Console.WriteLine(test1);
7+
Laptop test2 = new Laptop(12, "ThinkPenguin");
8+
Console.WriteLine(test2);
9+
10+
}
11+
12+
}

0 commit comments

Comments
 (0)