Intro to Computer Science Class #2 Administrative Details and Introduction to Objects Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie,

Slides:



Advertisements
Similar presentations
How to study for A&P Adapted from “get ready for A&P” By Lori K. Garrett.
Advertisements

Lecture 2 Calling and Defining Methods in Java. Introduction ●Calling and defining methods ●Declaring and defining a class ●Instances of a class ●The.
Object Oriented Programming in Java George Mason University Fall 2011
Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
Modules and Objects Introduction to Computing Science and Programming I.
Introduction to Computers and Java Recitation - 01/11/2008 CS 180 Department of Computer Science, Purdue University.
Intro to Computer Science Class #4 If Statements, While Loops and For Loops Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie, Siraaj,
Computers: Tools for an Information Age
CSc 160 Overview of Fundamentals of Computer Programming II Spring (SO1) 2004.
Structured Programming and UML Overview Session 2 LBSC 790 / INFM 718B Building the Human-Computer Interface.
CS211 Data Structures Sami Rollins Fall 2004.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
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.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
Conversational Computers
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
1 CS1130 Spring 2011: David Gries & Walker White Transition to Object-Oriented Programming Assumes programming knowledge in a language like Matlab, C,
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
CSE 501N Fall ‘09 00: Introduction 27 August 2009 Nick Leidenfrost.
COMP Introduction to Programming Yi Hong May 13, 2015.
Programming. What is a Program ? Sets of instructions that get the computer to do something Instructions are translated, eventually, to machine language.
Java Language and SW Dev’t
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
Computer Science 10: Introduction to Computer Science Dr. Natalie Linnell with credit to Cay Horstmann and Marty Stepp.
JAVA BASICS: Variables and References SYNTAX, ERRORS, AND DEBUGGING.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Computer Science II 810:062 Section 01. How is CS I different from CS II? When you teach Java there are a series of decisions that have to be made…
Salman Marvasti Sharif University of Technology Fall 2014.
CS61B L02 Using Objects (1)Garcia / Yelick Fall 2003 © UCB Kathy Yelick Handout for today: These lecture notes Computer Science 61B Lecture 2 – Using Objects.
CIT 590 Intro to Programming First lecture on Java.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Introduction to computers and programming Instructor: Alex Iskold.
Intro to Computer Science Class #3 Formalizing Variables, Methods and Inheritance Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie, Siraaj,
Course Overview ENGL 3365 Spring Copyright 2013 by Art Fricke basics The Instructor Dr. Art Fricke BS in Chemical Engineering & Biochemistry MS.
Lesson 1: Writing a program. Java Java is a programming language Computer cannot understand it, though it can be translated ( compiled ) so a computer.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
1 Intro to Computer Science Arrays Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie, Siraaj, Isaiah, Allison, Thibault University of.
BIT 143: Programming – Data Structures It is assumed that you will also be present for the slideshow for the first day of class. Between that slideshow.
CS2102: Lecture on Abstract Classes and Inheritance Kathi Fisler.
Computer Science Reaching Wider Summer School 2012.
Written by: Dr. JJ Shepherd
Winter 2016CISC101 - Prof. McLeod1 CISC101 Elements of Computing Science I Course Web Site: The lecture outlines.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
US Collaborating Schools Session 2 Module 1 Week 1 1.
1 CS100J Spring Instructor: David Gries CS100M: Matlab No prior programming experience One semester of calculus Math & engineering type problems.
CS 177 Recitation Week 1 – Intro to Java. Questions?
Week91 APCS-A: Java Problem Solving November 2, 2005.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Intro to Computer Science Class #8 Exceptions and I/O Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie, Siraaj, Isaiah, Allison, Thibault.
Content Programming Overview The JVM A brief look at Structure – Class – Method – Statement Magic incantations – main() – output Coding a Dog Programming.
Content Programming Overview The JVM A brief look at Structure
Lesson 2: Building Blocks of Programming
Introduction to Computer Programming
Week 1 - Friday COMP 1600.
Presentation transcript:

Intro to Computer Science Class #2 Administrative Details and Introduction to Objects Instructor: Ms. Catherine Stocker Teaching Assistants: Alex, Katie, Siraaj, Isaiah, Allison, Thibault University of Pennsylvania 30 January 2008

Today’s Agenda New Teaching Assistants Discussion (Reaction paper) Class Rules What is Java? BotPlay

New Teaching Assistants Let’s all introduce ourselves one more time.

Discussion Let’s talk about the reaction paper.

Attendance/Participation I will take attendance at the beginning of every class. –Don’t be late –Don’t be disruptive –Do your work If you are late or absent, bring me a note. Questions and discussion are highly encouraged!

Stuff You Should Already Know DON’T COPY CODE –It’s easy to spot. –It only hurts you – the material builds on itself. –When does giving/getting help cross the line to cheating? Course website: –I will also try to post other helpful links on the resources page of the course website. resources page

General Layout of Class 1:30-1:45 – Attendance and Discussion 1:45-2:30 – Lecture 2:30-2:40 – Short Break 2:40-3:30* – Lab Work (*Sometimes 30 min guest speakers) I will teach for this class and the next, then the teaching assistants will start running the class, while I supervise and help out. You will be assigned a programming assignment each week which you are expected to turn in before class the next week.

What to do if you’re stuck… 1)Try things out! Don’t be scared of the computer. (Just make sure to have a backup copy of your work!) 2)Check out the resources pageresources page 3)Post to the bulletin board!bulletin board 4)Come talk to us (before/after class). 5) me

What is Java? A high-level, object-oriented, programming language Language: –A way for people to communicate… With Humans: Use human languages (English, Spanish, Chinese, …) With Computers: Use programming languages (Java, C++, Python,...) –Made of vocabulary and syntax (rules for how to arrange the vocabulary)

What is Java? A high-level, object-oriented, programming language Language: –A way for people to communicate… With Humans: Use human languages (English, Spanish, Chinese, …) With Computers: Use programming languages (Java, C++, Python,...) –Made of vocabulary and syntax (rules for how to arrange the vocabulary)

What is Java? A high-level, object-oriented, programming language Language: –A way for people to communicate… With Humans: Use human languages (English, Spanish, Chinese, …) With Computers: Use programming languages (Java, C++, Python,...) –Made of vocabulary and syntax (rules for how to arrange the vocabulary)

What is Java? A high-level, object-oriented, programming language Language: –A way for people to communicate… With Humans: Use human languages (English, Spanish, Chinese, …) With Computers: Use programming languages (Java, C++, Python,...) –Made of vocabulary and syntax (rules for how to arrange the vocabulary) English: –Vocabulary: Anything in an English dictionary. –Syntax: How to arrange noun, verb and prepositional phrases, etc

What is Java? A high-level, object-oriented, programming language Language: –A way for people to communicate… With Humans: Use human languages (English, Spanish, Chinese, …) With Computers: Use programming languages (Java, C++, Python,...) –Made of vocabulary and syntax (rules for how to arrange the vocabulary) English: –Vocabulary: Anything in an English dictionary. –Syntax: How to arrange noun, verb and prepositional phrases, etc Java: –Vocabulary and Syntax: Keywords, and rules for arranging those key words, that you will learn in this class! »You learned some keywords already: int, char, boolean, String »You also already learned some syntax: int a = 5; boolean b = true;

What is Java? A high-level, object-oriented, programming language High-level: High-level of abstraction Abstraction: Hiding unimportant details –“The ball broke the window.” Does it matter what kind of ball? What color? The speaker abstracted away unimportant details of the ball. –Similarly in programming languages If we programmed in “machine language” (a lower-level language) we would have to write it specifically for that computer. Programming in Java, we are choosing to ignore details about any specific computer and focus on what all computers have in common. This program will then be translated by another program to a language specific to that machine.

What is Java? A high-level, object-oriented, programming language High-level: High-level of abstraction Abstraction: Hiding unimportant details –“The ball broke the window.” Does it matter what kind of ball? What color? The speaker abstracted away unimportant details of the ball. –Similarly in programming languages If we programmed in “machine language” (a lower-level language) we would have to write it specifically for that computer. Programming in Java, we are choosing to ignore details about any specific computer and focus on what all computers have in common. This program will then be translated by another program to a language specific to that machine.

What is Java? A high-level, object-oriented, programming language Hardware (CPU) (electrical impulses) Machine Language (0’s and 1’s) Bytecode Java Source Code (i.e. what you’ve written, held in a.java file) Compiler compiles (translates) it into bytecode (held in a.class file) Java Virtual Machine figures out how to run it on your computer

What is Java? A high-level, object-oriented, programming language Object-Oriented: Thinking about your program as a collection of objects that have a state and a behavior. Similar to the way we think about the world. –Example: Object = Horse State = name, hungry, mph Behavior = eat, walk, gallop, jump Other ways to think about your program: functional, procedural…we won’t look into these Horse name hungry mph horsey yes 5

Other Objects

How We Define An Object Depends On How We’re Going To Use It Abstract away the unnecessary details – only keep the important (relevant to the program) ones in the state. Program: Keep track of baseball stats –Object: Baseball Player –State: name, G, AB, R, H, HR, on base, at bat, –Behavior: run, walk, hit ball, slide, batting Baseball Player name G AB Ryan H R H HR onBase atBat RBI 3 no 353

How We Define An Object Depends On How We’re Going To Use It Abstract away the unnecessary details – only keep the important (relevant to the program) ones in the state. Program: Simulate how athletes lifestyles affect their popularity with fans, salary and injury rate –Object: Athlete –State: name, sport, salary, days injured, popularity –Behavior: negotiate contract, party, complain, retire Athlete name Ryan H sport baseball salary 900,000 daysInjured 25 popularity high

Other Objects

How Do We Translate What We’ve Talked About Into Java? class Athlete { String name ; String sport; int salary; int daysInjured; String popularity; Athlete(String n, String s) { name = n; sport = s; salary = 0; daysInjured = 0; popularity = “average”; } void negotiateContract(int newSalary) { salary = newSalary; } void party() { daysInjured = daysInjured + 10; } void complain() { popularity = “low”; } void retire() { salary = 0; popularity = “high”; } void printStates() { System.out.println(“name: “ + name + “, sport: “ + sport + “, salary: “ + salary + “, daysInjured: “ + daysInjured + “, popularity”); } }

How Do We Translate What We’ve Talked About Into Java? class Athlete { String name ; String sport; int salary; int daysInjured; String popularity; Athlete(String n, String s) { name = n; sport = s; salary = 0; daysInjured = 0; popularity = “average”; } void negotiateContract(int newSalary) { salary = newSalary; } void party() { daysInjured = daysInjured + 10; } void complain() { popularity = “low”; } void retire() { salary = 0; popularity = “high”; } void printStates() { System.out.println(“name: “ + name + “, sport: “ + sport + “, salary: “ + salary + “, daysInjured: “ + daysInjured + “, popularity”); } } The state or instance variables an object will have.

How Do We Translate What We’ve Talked About Into Java? class Athlete { String name ; String sport; int salary; int daysInjured; String popularity; Athlete(String n, String s) { name = n; sport = s; salary = 0; daysInjured = 0; popularity = “average”; } void negotiateContract(int newSalary) { salary = newSalary; } void party() { daysInjured = daysInjured + 10; } void complain() { popularity = “low”; } void retire() { salary = 0; popularity = “high”; } void printStates() { System.out.println(“name: “ + name + “, sport: “ + sport + “, salary: “ + salary + “, daysInjured: “ + daysInjured + “, popularity”); } } The behaviors or methods of the object. They can change the state/instance variables or show us the state when we ask.

How Do We Translate What We’ve Talked About Into Java? class Athlete { String name ; String sport; int salary; int daysInjured; String popularity; Athlete(String n, String s) { name = n; sport = s; salary = 0; daysInjured = 0; popularity = “average”; } void negotiateContract(int newSalary) { salary = newSalary; } void party() { daysInjured = daysInjured + 10; } void complain() { popularity = “low”; } void retire() { salary = 0; popularity = “high”; } void printStates() { System.out.println(“name: “ + name + “, sport: “ + sport + “, salary: “ + salary + “, daysInjured: “ + daysInjured + “, popularity”); } } Ryan Howard is not the only Athlete. He is one of many. The “blueprint” for an Athlete is laid out in this class. An object is an instance of a class. The class tells us how to set up the “state box” we’ve been drawing. But we don’t actually draw it until we create an object.

How Do We Translate What We’ve Talked About Into Java? class Athlete { String name ; String sport; int salary; int daysInjured; String popularity; Athlete(String n, String s) { name = n; sport = s; salary = 0; daysInjured = 0; popularity = “average”; } void negotiateContract(int newSalary) { salary = newSalary; } void party() { daysInjured = daysInjured + 10; } void complain() { popularity = “low”; } void retire() { salary = 0; popularity = “high”; } void printStates() { System.out.println(“name: “ + name + “, sport: “ + sport + “, salary: “ + salary + “, daysInjured: “ + daysInjured + “, popularity”); } } The constructor. This is where we set up the starting state by assigning values to the instance variables.

Now… Let’s play with that Athlete code. BotPlay (

Later… Write a class of your own. Include at least 2 instance variables and 2 methods that change those instance variables. Write down something you were confused about from class and a short explanation about what confused you (1-3 sentences).