



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CSE 1301
Using Classes
Figures from Lewis, “C# Software Solutions”, Addison Wesley
Briana B. Morrison
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
Class contains Members are Fields
Methods
Instance variables Class variables
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
Syntax: ClassName objectReference; or ClassName objectRef1, objectRef2…;
Constructor: special method that creates an object and assigns initial values to data
Date Class Constructor Summary Date( ) creates a Date object with initial month, day, and year values of 1, 1, 2000 Date( int mm, int dd, int yy ) creates a Date object with initial month, day, and year values of mm , dd , and yy
CSE 1301 (^) 3A-
Date aDate; aDate.setMonth( 5 );
Date independenceDay = new Date( 7, 4, 1776 ); // set object reference to null independenceDay = null; // attempt to use object reference independenceDay.setMonth(5);
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
Insert .NET example here
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 (^) 3A-
CSE 1301 3-393A-39^ CSE 1301 3-403A-
CSE 1301 3-413A-41^ CSE 1301 (^) 3A-