Lec 07 Classes and Objects

Lec 07 Classes and Objects - FIT1002 Computer Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: FIT1002 Computer Programming Module 7 Writing Classes www.monash.edu.au FIT1002 Computer Programming Module 7 Classes & Objects COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University pursuant to Part VB of the Copyright Act 1968 (the Act). The material in this communication may be subject to copyright under the Act. Any further reproduction or communication of this material by you may be the subject of copyright protection under the Act. Do not remove this notice. The authors acknowledge that material in these modules has been adapted from slides produced by Lewis, DePasquale and Chase for Java Foundations: Introduction to Programming and Data Structures , Addison-Wesley, 2007 2 Assumed Knowledge Before the beginning of this lecture, students should be familiar with: Defining simple methods Module 3 Objects and Classes revise how to use the predefined classes String and Scanner Before the beginning of this lecture, students should have read over: Notes in the Study Guide for Module 7 3 3 Objectives Explain the concepts of attributes and behaviors, constructors, encapsulation and messaging; Explain the different between an object and a class; Instantiate and send messages to objects; Know the basic structure and content of a class definition and be able to create a basic class in Java; Explain the use of the public and private modifiers; Write a simple driver class to control an object oriented program FIT1002 Computer Programming Module 7 Writing Classes 4 Classes and Objects Revisited The notions of a class and an object were introduced back in Week 3 At the time you saw classes that exist within Java to help us do specific operations or help us manage certain types of data For example: String class Math class The essence of Object Oriented program development however is in writing our own classes 5 Why make our own classes We want a way of representing things from the real world inside our programs We want related data about single entities to be kept together It can be helpful to think about how the entities might behave in the real world, and model this by behaviors in a program Javas designers could not possibly have known what things we want to deal with in our programs 6 Objects An object: represents some individual thing from the world; has attributes that are assigned values stored in a set of instance variables; has behaviours specified by a set of methods. These methods often change and/or use the objects data. Attributes Behaviours An object FIT1002 Computer Programming Module 7 Writing Classes 7 Examples of Objects Here are three different types of objects: Dog, Clock/Time, and Coin What data might we store for each?...
View Full Document

This note was uploaded on 08/15/2010 for the course FIT 1002 taught by Professor Mylini during the Three '10 term at Monash.

Page1 / 19

Lec 07 Classes and Objects - FIT1002 Computer Programming...

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

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