using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Interfaces2 { interface university { void uni_details(string uname); } interface college { void col_details(string cname,string loc); } class student : university, college { string name, cname, uname, course, loc; int s1, s2, s3, age; public void uni_details(string name) { uname = name; } public void col_details(string name, string location) { cname = name; loc = location; } public void read(string name, int s1, int s2, int s3, string course, int age) { this.name = name; this.s1 = s1; this.s2 = s2; this.s3 = s3; this.course = course; this.age = age; } public void cal() { int sum = s1 + s2 + s3; double avg = (double)(sum / 3.0); Console.WriteLine("Name: " + name + "\n" + "Age: " + age + "\n" + "Course: " + course); Console.WriteLine("University: " + uname); Console.WriteLine("Subject-1: " + s1 + "\n" + "Subject-2: " + s2); Console.WriteLine("Subject-3: " + s3); Console.WriteLine("Total: " + sum); Console.WriteLine("Average: " + avg); } } class Program { static void Main(string[] args) { student s = new student(); s.uni_details("Azad University"); s.col_details("Komeil", "Shahr-e Kord"); s.read("Kamran", 97, 89, 84, "M.Sc", 24); s.cal(); } } }
7/14/2010
C# Interface (2)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment