Skip to content

Instantly share code, notes, and snippets.

@Cxarli
Created May 22, 2016 16:54
Show Gist options
  • Select an option

  • Save Cxarli/592e145bc39d6d3d671eeee2fab31dfc to your computer and use it in GitHub Desktop.

Select an option

Save Cxarli/592e145bc39d6d3d671eeee2fab31dfc to your computer and use it in GitHub Desktop.
using System;
namespace Test {
class MainClass {
public static void Main(string[] args) {
Student charlie = new Student ("Charlie", 7);
charlie.WhoAreYou();
}
}
class Person {
private string name;
public Person (string name) {
this.name = name;
}
public void Greet () {
Console.WriteLine ("Greetings from " + this.name);
}
}
class Student : Person {
private int averagegrade;
public Student (string name, int averagegrade) : base(name) {
this.averagegrade = averagegrade;
}
public void WhoAreYou () {
Greet ();
Console.WriteLine ("My average grade is a " + this.averagegrade);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment