/
2.2 Defining Classes Part 2 2.2 Defining Classes Part 2

2.2 Defining Classes Part 2 - PowerPoint Presentation

myesha-ticknor
myesha-ticknor . @myesha-ticknor
Follow
344 views
Uploaded On 2019-06-28

2.2 Defining Classes Part 2 - PPT Presentation

academyzaribacom 1 Lecture Content BunniesVersusZombies Code Review Namespaces Structures Generics indexers and operator overloading 2 1 Code Review 3 Bunnies Zombies 2 Namespaces ID: 760466

element structures list create structures element create list fields classes index overload namespaces types homework matrix operations properties bunnies

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "2.2 Defining Classes Part 2" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

2.2 Defining Classes Part 2

academy.zariba.com

1

Slide2

Lecture Content

BunniesVersusZombies Code ReviewNamespacesStructuresGenerics, indexers and operator overloading

2

Slide3

1. Code Review

3

Bunnies

Zombies

Slide4

2

. Namespaces

4

Bunnies

Zombies

Slide5

3. Structures

5

What is a structure in C#?

Unlike classes, structures are value types.

Structures behave like primitive types (

int

, double…)

Structures can have properties, methods, fields, constructors, events, etc.

Mostly used to store data (fields), e.g. points in 2D, 3D space

Slide6

4. Generics, indexers andoperator overloading

6

Slide7

Homework

7

Organize your previous homework into separate files, namespaces and folders. Decouple your classes with the Console. Fix all

StyleCop

errors that arise.

Create a class Fraction with the properties/fields numerator,

denominator, value

(string which will return for example “1/2”) and decimal value (e.g. “0.5”). Perform the necessary validations when creating a new Fraction. Overload the operators “+”, “-”, “*”, “/”. Test your application with different calculations.

Create a class Matrix which corresponds to the mathematical definition of a matrix. Overload the operators “+”, “-” and “*”. Check if those operations can be performed at all (validation). Test all of your operations.

Create your own Generic List (called

myList

). Implement the following: Accessing by index, removing element by index, inserting element at a given position, adding an element to the list, clearing the list, finding element by value and

ToString

().

Slide8

8

References

Slide9

9

Zariba Academy

Questions