//additional method 2 public void makeClass2(ClassC _class2) { //instantiate the other class mClass1 = new ClassA(_class2); //print out class name and parameter Console.WriteLine("ClassB method with parameter: ClassC"); }
//parameter class constructor 2 public ClassB(ClassC _class2) { //assign parameters to member variables mClass2 = _class2; //print out class name with parameter Console.WriteLine("ClassB with parameter: ClassC"); }
//additional method 1 public void makeClass(ClassB _class1) { //instantiate the other class mClass2 = new ClassC(_class1); //print out class name and parameter Console.WriteLine("ClassA method with parameter: ClassB"); }
//final method public void finalMethod(ClassA _class1, ClassC _class2) { //call method 1 and 2 makeClass(_class1); makeClass2(_class2); //print out to console Console.WriteLine("ClassB calling both methods"); }
static void Main(string[] args) { /* * Cody Maxwell * 11-23-2016 * MDV2430-O * Code Exercise 01: Classes and Methods */ //instantiate 3 classes with constructors ClassA initialClass1 = new ClassA("custom string", 182, 30.12); ClassB initialClass2 = new ClassB("second custom string", true, 561); ClassC initialClass3 = new ClassC(9, 50.50, false); //call class A final method initialClass1.finalMethod(initialClass2, initialClass3); //call class B final method initialClass2.finalMethod(initialClass1, initialClass3); //call class C final method initialClass3.finalMethod(initialClass1, initialClass2); }