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

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

Engineering Computation ENG 1D04 Lecture 9: More…Classes Mihai Albu

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

View Full Document
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
2 Classes class test { int x; int y; public void Add() { x = x + y; } } test MyTest = new test(); MyTest.Add();

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

View Full Document
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; } }
4 test t1 = new test(); test t2 = new test(); MessageBox.Show(Convert.ToString(test.GetCount()));

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

View Full Document
5 Dependencies if (str1.CompareTo(str2) == 0) MessageBox.Show(“Same Strings”);
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()); } }

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

View Full Document
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);
8 Aggregation An object made up from other objects. Aggregation == “has a” relationship

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online