1 COS 260 DAY 2 Tony Gauvin. 2 Agenda Questions? Class roll call Blackboard Web Resources Objects and classes 1 st Mini quiz on chap1 terms and concepts.

Slides:



Advertisements
Similar presentations
Using Java without BlueJ BlueJ projects A BlueJ project is stored in a directory on disk. A BlueJ package is stored in several different files.
Advertisements

More Sophisticated Behaviour 1 Using library classes to implement more advanced functionality.
Fields, Constructors, Methods
Using interfaces Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling How would you find the maximum.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 2 Stewart Blakeway FML 213
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Objects First with Java A Practical Introduction using BlueJ
String Concatenation (operator overloading) 3.0.
Understanding class definitions Looking inside classes 3.0.
COMS W1004 Introduction to Computer Science June 1, 2009.
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
Objects & Object-Oriented Programming (OOP) CSC 1401: Introduction to Programming with Java Week 15 – Lecture 1 Wanda M. Kunkle.
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
Understanding class definitions – Part II –. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main.
Using Java without BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling BlueJ projects A BlueJ.
COS 125 DAY 5. Agenda Questions from last Class?? Assignment #2 posted Due Feb 15 We will discuss in class Capstone proposals due Feb 15 Suggestion is.
Using Java without BlueJ
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
1 CSC 221: Computer Programming I Fall 2004 Objects and classes: a first pass  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Object Oriented Design: Identifying Objects
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction to Java. 2 Textbook David J. Barnes & Michael Kölling Objects First with Java A Practical Introduction using BlueJ Fourth edition, Pearson.
OBJECTS AND CLASSES CITS1001. Concepts for this lecture class; object; instance method; parameter; signature data type multiple instances; state method.
1 COS 260 DAY 1 Tony Gauvin. 2 Agenda Class roll call Instructor Introduction Instructor’s Educational Philosophy Contract on Classroom Behavior Syllabus.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Chapter 1 Object Orientation: Objects and Classes.
1 CSC 221: Computer Programming I Spring 2008 Objects and classes: a broad view  software objects, classes, object-oriented design  BlueJ IDE, compilation.
COS 260 DAY 5 Tony Gauvin.
Understanding class definitions
1 COS 260 DAY 3 Tony Gauvin. 2 Agenda Questions? 1 st Mini quiz on chap1 terms and concepts –Today In BlackBoard –30 min., M/C and short answer, open.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
1 COS 260 DAY 19 Tony Gauvin. 2 Agenda Questions? 8 th Mini Quiz not corrected yet 9 Th Mini Quiz next class –Due November 19 Finish Discussion on More.
1 COS 260 DAY 10 Tony Gauvin. 2 Agenda Questions? 4 th Mini quiz Today –Chapter 4 Assignment 2 Due Capstone Discussion Proposals Due Oct 15 No class on.
1 COS 260 DAY 14 Tony Gauvin. 2 Agenda Questions? 6 th Mini quiz graded  Oct 29 –Chapter 6 Assignment 4 will be posted later Today –First two problems.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
1 COS 260 DAY 21 Tony Gauvin. 2 Agenda Questions? 8 th Mini Quiz corrected –Good results 9 Th Mini Quiz Today –40 min covering Chap 9 Assignment 5 Due.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
1 COS 260 DAY 17 Tony Gauvin. 2 Agenda Questions? 7 th Mini quiz –Chapter 7 –Password “GoBengals” –40 min Assignment 4 posted –Due Nov 9 (one week) Capstone.
1 COS 260 DAY 22 Tony Gauvin. 2 Agenda Questions? 9 th Mini Quiz corrected –Good results Assignment 5 Not corrected yet Assignment 6 Posted (one more)
1 COS 260 DAY 18 Tony Gauvin. 2 Agenda Questions? 7 th Mini quiz Graded –Good results 8 th Mini Quiz –Chap 8  Next class Assignment 4 Due Assignment.
Objects First With Java A Practical Introduction Using BlueJ Using Java without BlueJ 1.0.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
6.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Chapter 1 Object Orientation: Objects and Classes.
Objects and Classes CITS1001 week 1.
COS 260 DAY 1 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
Programming Language Concepts (CIS 635)
Trainings 11/4 Intro to Java.
Objects First with Java A Practical Introduction using BlueJ
Java Programming with BlueJ
Understanding class definitions
COS 260 DAY 6 Tony Gauvin.
Principles of Computer Programming (using Java) Chapter 2, Part 1
Your First Java Application
COS 260 DAY 11 Tony Gauvin.
COS 260 DAY 10 Tony Gauvin.
COS 260 DAY 2 Tony Gauvin.
COS 260 DAY 3 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
Understanding class definitions
COS 260 DAY 4 Tony Gauvin.
COS 260 DAY 23 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
COS 260 DAY 6 Tony Gauvin.
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Presentation transcript:

1 COS 260 DAY 2 Tony Gauvin

2 Agenda Questions? Class roll call Blackboard Web Resources Objects and classes 1 st Mini quiz on chap1 terms and concepts –September 10 –30 min., M/C and short answer, open book, open notes, open computer Assignment 1 posted in Blackboard –Chap1 & 2 –Due September 17 prior to class

3 Getting what you need 1.Java JDK – avase/downloads/jdk8-downloads htmlhttp:// avase/downloads/jdk8-downloads html –Pick the Kit for your OS 2.BlueJ – –Download BlueJ installer for your OS 3.Projects for Class (and other resources) – Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling

5 Objects and classes objects –represent ‘things’ from the real world, or from some problem domain (example: “the red car down there in the car park”) classes –represent all objects of a kind (example: “car”) Object Oriented Programmers write class code and invoke objects Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

6 Objects and Classes vaOne06.html vaOne06.html Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

7 Class Object

8 Methods and parameters Objects have operations which can be invoked (Java calls them methods). Methods may have parameters to pass additional information needed to execute. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

9 Other observations Many instances can be created from a single class. An object has attributes: values stored in fields. Attributes describe the object’s “state” The class defines what fields an object has, but each object stores its own set of values (the state of the object). Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

10 State Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

11 Two circle objects Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

12 Java Data Types Integers  int, byte, short and long –2, , -56, 111 Real numbers  float and double –58.45, Logic  boolean –true, false Character  char –‘A’, ‘a’, ‘&’, ‘=‘, ‘1’, Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

13 Source code Each class has source code (Java code) associated with it that defines its details (fields and methods). Code is stored in a “*.java” file where * is the name of the class Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

14 Java Code Person person1 = new person(); person1.makevisible(); person1.moveright(); person1.moveHorizontal(50); Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

15 Methods Method signature Return_Value method_name(parameter_type para meter_name); void moveHorizontal(int distance); Method Invocation object_name.method_name(parameters); circle1.moveHorizontal(40); Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

16 Return values All the methods in the figures project have void return types; but … … methods may return a result via a return value. Such methods have a non- void return type. More on this in the next chapter. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

17 Make this picture Use figures project (hint: use terminal window with record methods options to see java code being implemented Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

18 Make this animation Use moveSlowHorizontal & and moveSlowVertical to make the child walk up the hill to stand beside the parent Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

19 Learning Java Code Instead of using the right mouse clicks on object bar we can use BlueJ Code pad to type in Java code directly Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Code Pad

20 Writing Java Code Using editor Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

21 Modifying Code Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Using editor modify code for picture to add a chimney in house project

22 Creating A database Open lab-classes project Create students using visual controls and code pad Using object bench and code pad and monitor terminal window –getName() –getCredits() Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

23 Objects AS Parameters Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Student br = new Student( "Barney", "YYY"); labClass1.enrollStudent(br); Do exercise 1.27, 1.28 & 1.29 on page 16

24 Terms for Today (and for mini-quiz) Object Class Instance Method Signature parameter Type State Source code Return value Compiler Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling