1 CS1130 Spring 2011: David Gries & Walker White Transition to Object-Oriented Programming Assumes programming knowledge in a language like Matlab, C,

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 20 th, 2009.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
22-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
0 CS100J September 2007 CS100J: 12 weeks programming using Java, 2 using Matlab. David Gries. CS100M: 7 weeks of Matlab and 7 of Java. Daisy Fan. CS100H:
COMS W1004 Introduction to Computer Science June 1, 2009.
Honors 101, Fall 2006 Please do not sit in back of room! Lots of info on web page Join the mailing list Download Eclipse and start using it Read the text.
Lecture 2: Topics Bits and Bytes Primitive Types Casting Strings Boolean expressions.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
CS/ENGRD 2110 SPRING 2015 Lecture 1: Overview and intro to types
1 CS1110 Fall 2011: David Gries & Steve Marschner CS1112: Matlab No prior programming experience One semester of calculus Math- & engineering- type problems.
CS/ENGRD 2110 SPRING 2015 Lecture 1: Overview and intro to types
2015/8/221 Data Types & Operators Lecture from (Chapter 3,4)
CS/ENGRD 2110 FALL 2013 Lecture 1: Overview and intro to types
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
1 CS1110 Fall 2010 Instructors: David Gries & Lillian Lee CS1112: Matlab No prior programming experience One semester of calculus Math- & engineering-
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
CIS Computer Programming Logic
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
1 CS1110. Lecture 1, 31 Aug Types, expressions, variables, assignment statements Can’t install DrJava and running a Microsoft operating system? Contact.
CS100J Spring 2006 CS100J: 11 weeks of programming using Java and 2 weeks using Matlab. David Gries is teaching CS100J. Graeme Bailey is teaching a special.
Java 2 More Java Then Starbucks ;-). Important Terms Primitive Data – Basic, built-in values (characters & numbers) Data Type – Used to talk about values.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
1 CS1110 Fall 2011 David Gries, Steve Marschner Reading for this lecture and previous lecture: Sections 1.1, 1.2, 1.3. Lab 1 will give you practice with.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
Number Representation, Data Types and Elementary Programming Shirley Moore CS 1401 February 5-7, 2013.
1 CS1110. Lecture 1, 31 Aug Types, expressions, variables, assignment statements Summary of lectures : On course webpage, click on “Lecture summaries”.
1 CS1100 Fall Instructor: David Gries CS100M: Matlab No prior programming experience One semester of calculus Math & engineering type problems CS100J:
Primitive Variables.
1 CS1110 Fall Instructors: David Gries & Lillian Lee CS1112: Matlab No prior programming experience One semester of calculus Math- & engineering-
Java Programming, Second Edition Chapter Two Using Data Within a Program.
COMP Primitive and Class Types Yi Hong May 14, 2015.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
1 10/3/05CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Fundamental Programming Fundamental Programming More Expressions and Data Types.
LESSON 5 – Assignment Statements JAVA PROGRAMMING.
1 CS100J Spring Instructor: David Gries CS100M: Matlab No prior programming experience One semester of calculus Math & engineering type problems.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
Georgia Institute of Technology Introduction to Java, and DrJava part 1 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
1 CS Sept Customizing a class & testing Quote for the day: There is no reason anyone would want a computer in their home. - -Ken Olson, founder.
CS1110 Spring Instructor: David Gries
Chapter 7: Expressions and Assignment Statements
Object Oriented Programming
Chapter 7: Expressions and Assignment Statements
Primitive Data, Variables, Loops (Maybe)
Type Conversion, Constants, and the String Object
Building Java Programs Chapter 2
Principles of Computer Programming (using Java) Chapter 2, Part 1
Computers & Programming Languages
Relational Operators Operator Meaning < Less than > Greater than
CS/ENGRD 2110 Fall 2018 THERE IS ROOM IN THE BALCONY!
Introduction to Java, and DrJava part 1
Building Java Programs
Introduction to Java, and DrJava
Java Programming Review 1
CS100J CS100M is in Kimball Bll.
Java’s Central Casting
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Review of Java Fundamentals
Presentation transcript:

1 CS1130 Spring 2011: David Gries & Walker White Transition to Object-Oriented Programming Assumes programming knowledge in a language like Matlab, C, C++, or Fortran. Students who have learned Java but were not exposed heavily to OO are welcome. Course Outcome: Understand OO concepts, as used in Java: classes, subclasses, inheritance, and overriding. This includes an operational model of method calls and the basics of OO design. Lectures: M, F 2:30 or 3:35 Lab: W 2:30 or 3:35 or 7:00 (no need to attend but work must be done by end of the week) website:

2 1.Labs. Weekly, in Holl. B14. Bring laptop. TAs/consultants will help. 2.Quizzes. Let you know what material is important for you to know at that point. Quizzes require mastery: take them until you pass. 3.Course text: CD at the back of book has minute lectures, each on 1 specific point. CD missing? See course website. 4.Two prog assignments require mastery. Submit, get feedback, resubmit, … until it is right. 5.Two tests require mastery. 6.Piazza. Our “town square” —ask and answer questions. 7.Consultants available for help in Green room of ACCEL lab. Visit course website to find schedule.

3 Academic Integrity. We ask you not to cheat, in any way, shape, or form. On our side, we try our best to be fair about the amount of work, in grading the work, and in giving you a course grade. For more info, see course website. Do Quiz 0 on Course CMS. Course Management System. AFTER TUESDAY: Visit cms.csuglab.cornell.edu/ CS1130lectures not listed? Maria Witlox, ask to add you to CS1130lectures. Include your Cornell netid in your

Four things to do 4 1. AFTER TUESDAY: Get on Course Management System (CMS). Get to it from link on course website. Not registered on our CMS? Maria Witlox and ask her to register you. She needs your netid. course website: 2. Get DrJava onto your computer. See course website, Piazza for info. Problems with it? You can wait, but do try. 3. Academic Integrity. Read about it on course website. Visit CMS and do Quiz Read in course text (see next slide)

5 Reading for this and the next lecture: Sections 1.1, 1.2, 1.3. Lab 1: practice with concepts and details of 1.2, 1.3. You will not understand all the reading because there are many new terms, but doing the reading will enhance next lecture. PLive: Lesson 0, Lesson page 1.3, Activity Summary of lectures: On course website, click “Lecture summaries”. Today Introduce types, expressions, variables in Show you around the CD PLive DrJava. We write programs using the free IDE (Integrated Development Environment) called DrJava. Download it from the course website.

6 Type: A set of values together with operations on them. Type integer: values: …, –3, –2, –1, 0, 1, 2, 3, 4, 5, … operations: +, –, *, /, unary – Memorize definition!Write it down several times. Type int: values: – , – , …, –3, –2, –1, 0, 1, 2, 3, 4, 5, …, , operations: +, –, *, /, unary – – –1 Use Chapter 6 as a reference for primitive types!

Strongly typed versus weakly typed 7 Matlab: weakly typed. A variable can contain a number at one point, a string (of characters) at another point, and a 2-dimensional array at another point of execution. Java: strongly typed. A variable has to be declared with a type before it is used, and it can contain values only of that type. DrJava: Set a preference so that variables need not be declared in the interactions pane before they are used in the interactions pane. Menu item Edit -> Preferences; click on Interactions Pane. Variable: named box with a value in it. b 35 byte short int long float double char boolean 1 byte 2 bytes 4 bytes 8 bytes 4 bytes 8 bytes 2 bytes Primitive types

8 Type: A set of values together with operations on them. Type double: values: Examples: –22.51E6 equivalent to – or –22.51 * E–6 equivalent to or * 10 –6 An approximation to the real numbers. operations: +, –, *, /, unary – exponentmantissa Type boolean Values: true false Operators: and && or || not ! Use Chapter 6 as a reference for primitive types!

Declaration of a variable 9 Syntax: ; Examples int b; double d; String s; int[] c; double[][] a; b contains an int d contains a double s contains the name of a String object c contains the name of a 1-dim array object a contains the name of a 2-dim array object b 0 int d 0.0 double s a1 String c a2 int[] a a9 int[][]

Assignment statement 10 Syntax: = ; Semantics: To execute the assignment, evaluate the and store its value in the. Note: must be as “wide” or “wider” than b 0 int d 0.0 double d is wider than b b= b + 1; d= d*5 + b; d= b; b= d; is illegal. Won’t compile

Casting 11 d= (double) 4; (int) 3.5 is a cast; it casts double value 3.5 to type int byte -> short -> int -> long -> float -> double char -> int -> long -> float -> double narrow wide b 0 int d 0.0 double d is wider than b b= (int) 3.5; d= 4; 4 has to be cast to double; it is a widening cast, so Java does it automatically.

12 Precedence of operators (page 23) Unary operators: + – ! Binary arithmetic: * / % Binary arithmetic: + – Arithmetic relations: = Equality relations: == != Logical and: && Logical or: | | The next lecture will also discuss: Types boolean (p. 20) and String (p. 22) You will use these things in Lab 01.