Java Syntax, Java Conventions, CSE 115 Conventions (Part 2) CSE 115 Spring 2006 January 30, February 1 & 3, 2006.

Slides:



Advertisements
Similar presentations
Hamlet /Media Outline. I. Thesis Statement: (Director)s To be or not to be and (director)s Alas poor Yorick best exemplify William Shakespeares original.
Advertisements

Introduction to Java.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Lecture #5 Agenda Cell phones off & name signs out Review Questions? UML class diagram introduction Our first class definition!
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
1 Composition A whole-part relationship (e.g. Dog-Tail) Whole and part objects have same lifetime –Whole creates instance of part in its constructor In.
Data Types and Expressions
Java Syntax, Java Conventions, CSE 115 Conventions (Part 1) CSE 115 Spring 2006 January 25 & 27, 2006.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
Week 2 Recap CSE 115 – Spring Object Oriented Program System of objects that communicate with one another to solve some problem.
Week 6 Recap CSE 115 Spring Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,
1 Series RLC Resonant Circuit V s = 10 Vrms, R = 10 , L = 100 mH, C = 10  F VsVs R L C I + V R - + V L - +VC-+VC-   (varied) Assignment #1: Part.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Week 5 Recap CSE 115 Spring Composition Informally called “has a” Represented in UML with a diamond- headed arc In code: Declare an instance variable.
CSE 115 Week 3 January 28 – February 1, Monday Announcements Software Installation Fest: 2/5 and 2/6 4pm – 7pm in Baldy 21 Software Installation.
CSE 115 Week 4 February 4 - 8, Monday Announcements Software installation fest Tuesday & Wednesday 4-7 in Baldy 21. Software installation fest Tuesday.
JavaScript, Third Edition
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Week 3 Recap CSE 115 – Fall Java Source Code File Made up of: Package declaration Class definition.
UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation.
Objects CSE 115 Spring 2006 January 25, Object-Oriented Program System of objects that communicate with one another and work together to solve a.
© 2006 Pearson Education Making Objects 1 of 19 MAKING OBJECTS Views of a Class Defining Your Own Class Declaring Instance Variables Declaring Methods.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
CSE 115 Week 2 January , Wednesday Announcements Pick up Syllabus if you need one Pick up Syllabus if you need one Recitation Change Form.
Roman Numerals. Roman Numerals - Past and Present  Romans used them for trading and commerce.  When Romans learned to write they needed a way to write.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
PowerPoint Presentation  Section 16.2  Pages  53 Slides.
Comments are for people Header comments supply basic information about the artifact.
CSC 142 B 1 CSC 142 Java objects: a first view [Reading: chapters 1 & 2]
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
The Java Programming Language
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Classes CS 21a: Introduction to Computing I First Semester,
DATA REPRESENTATION, DATA STRUCTURES AND DATA MANIPULATION TOPIC 4 CONTENT: 4.1. Number systems 4.2. Floating point binary 4.3. Normalization of floating.
CET203 SOFTWARE DEVELOPMENT Session 1A Revision of Classes.
IB Computer Science Unit 1 – Introduction to Java Variables.
SE-1020 Dr. Mark L. Hornick 1 Composition, Aggregation, and Inheritance - Introduction.
Object Oriented Analysis and Design Class and Object Diagrams.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Roman Numeral Multiplication Quiz
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Class Fundamentals BCIS 3680 Enterprise Programming.
1 Урок 24 Тема урока:. 2 План урока 1.Русь в 14 веке. 2.Борьба Москвы с Тверью. 3.Иван Калита. 4.Начало правления Дмитрия Донского. 5.Московское княжество.
 2007 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
University of Central Florida COP 3330 Object Oriented Programming
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Unit-1 Introduction to Java
Roman Numerals.
Notes from Week 5 CSE 115 Spring 2006 February 13, 15 & 17, 2006.
Tutorial 10: Programming with javascript
Classes CS 21a: Introduction to Computing I
Chap 2. Identifiers, Keywords, and Types
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Presentation transcript:

Java Syntax, Java Conventions, CSE 115 Conventions (Part 2) CSE 115 Spring 2006 January 30, February 1 & 3, 2006

VII - Constructors Q: What is the job of the constructor? Identifying the constructor in code: public class SomeName { public SomeName() { Between the { } is the Java code that outlines what the functionality of the constructor is. }

VII – Constructors continued When we actually want to create an object, we need to activate the capability of the constructor, we do so by inserting the following line of code into our program: new NameOfConstructor();

VIII - Keywords Sometimes called reserved words, these words have a special meaning in Java and can only be used for that purpose within your code. Please note the listing of keywords for this semester linked off of the Resources page

IX - Identifiers Programmer defined names for program elements (“names”) Rules: 1)Begin with a letter or underscore 2)Followed by zero or more letters, numbers, underscores 3)No spaces or special characters allowed in identifiers 4)Keywords are not allowed to be identifiers

XI - Dependency Relationship between two classes Informally called “uses a” Represented in UML diagrams as a dotted arrow In code, if ClassA uses a ClassB: public class ClassA { public ClassA() { new ClassB(); }

XII - Packages package keyword indicates the class’ membership in a package. Packages are ways to organize code so that code with like purpose is kept together.

XIII - Comments Notes to help us remember/understand the code we write Two styles: // to the end of line comment /* Multi-line comment begin Multi-line comment ends with */

XIV - Composition Second relationship between classes Informally called “has a” Represented in UML with a diamond- headed arc In code:  Declare an instance variable  Create an instance of the component part  Assign that instance to the instance variable

XV - Variables Named storage

XVI – Instance Variables Variables that store information specific to a class – used to store all three types of properties discussed earlier. Declaring an instance variable: visibility type identifier;

XVII – Visibility Access control modifiers indicate who has access to something Visibilities are presented by keywords  private  public Q: What is the difference between the two types of visibilities?

XVIII – Type of a variable Java is strongly-typed When variables are declared, we must tell Java what type of thing the variable will hold on to

XIX – Identifiers for instance variables Begin with an underscore First letter of first word lower case First letter of subsequent words upper case _myFirstInstanceVariable