lec7 - 1.00 Lecture 7 Java Classes and Objects Reading for...

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

View Full Document Right Arrow Icon
1.00 Lecture 7 Java Classes and Objects Reading for next time: Big Java: sections 2.6-2.11 Classes A class is a pattern or template from which objects are made You may have many birds in a simulation One bird class (or more if there’s more than one type of bird) Many bird objects (actual instances of birds) Simulation Objects are instances of classes Class: Student Object: Joe Smith Class: Building Object: Building 10 Class: Street Object: Mass Ave
Background image of page 1

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

View Full DocumentRight Arrow Icon
Class Definition Classes contain: Data (members, fields) Simple data types, like int or double (e.g. bird weight) Objects (e.g. bird beak) Methods (functions, procedures) Actions that an object can execute (e.g. bird flies/moves) Classes come from: Java class libraries: JOptionPane, Array, Math, etc. There are several thousand classes (Javadoc) Class libraries from other sources: Web, fellow students… Classes that you write yourself Classes are usually the nouns in a problem statement (e.g. bird) Data members are also nouns (e.g., weight) Methods are usually the verbs (e.g. flies) Building Classes Classes hide their implementation details from the user (programmer using the already-written class): Their data is not accessed directly, and the details are not known to ‘outside’ objects or programs. Data is almost always
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 5

lec7 - 1.00 Lecture 7 Java Classes and Objects Reading for...

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

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