Lecture9 - Engineering Computation ENG 1D04 Lecture 9:...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering Computation ENG 1D04 Lecture 9: More…Classes Mihai Albu
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1 Announcements s Cheating is NOT allowed. s Hopefully, in the last week we will have a double session of quizzes => 4 out of 6
Background image of page 2
2 Classes class test { int x; int y; public void Add() { x = x + y; } } test MyTest = new test(); MyTest.Add();
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3 Static members s Variables that are shared among ALL instances of a class class test { private static int count = 0; public test() { count ++; } public static int GetCount() { return count; } }
Background image of page 4
4 test t1 = new test(); test t2 = new test(); MessageBox.Show(Convert.ToString(test.GetCount()));
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5 Dependencies if (str1.CompareTo(str2) == 0) MessageBox.Show(“Same Strings”);
Background image of page 6
6 Build you own class matr { private int size; public matr(int n) { size = n; } public int GetSize() { return size; } public bool Compare( matr compMatr) { return (size == compMatr.GetSize()); } }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
7 matr a = new matr(3); matr b = new matr(3); matr c = new matr(2); bool x = a.Compare(b); x = b.Compare(c);
Background image of page 8
8 Aggregation An object made up from other objects. Aggregation == “has a” relationship
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

Lecture9 - Engineering Computation ENG 1D04 Lecture 9:...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online