C#
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }
So..... you posted an unformatted code snippet and didn't describe a problem or ask a question. What are we supposed to do with this?
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }
I agree. This is C#.
Josh Davis
This is what plays in my head when I finish projects.