1 CS100J 30 January 2007 The class definition Course Management System (CMS) for CS100J is populated with students who were pre-registered. Look at course.

Slides:



Advertisements
Similar presentations
How to Change The Fading Images on Your Home Page and Other Pages
Advertisements

1 For more info: CS Sep 2008 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston to.
1 CS100J. Lecture 2, 25 January 2007 Today’s topic: Objects and classes Reading for this lecture: Section 1.3. It’s most important that you study this.
CS100J Today’s topic: Objects and classes Reading for this lecture: Section 1.3 PLive: Activities 3-3.1, 3-3.2, (not 3-3.3), 3-4.1, Summary.
1 CS Sept. Customizing a class & testing Quiz 2 on Tuesday 15 Sept Purpose of a constructor (slide 5) Evaluating a new expression (slide 6) Fields;
1 CS100J 1 February Customizing a class & testing Quote for the day: There is no reason anyone would want a computer in their home. - -Ken Olson,
1 Review of classes and subclasses M fast through this material, since by now all have seen it in CS100 or the Java bootcamp First packages Then classes.
CS100J 11 September 2003 Course Management System for CS100J is now populated with students who were pre-registered. Look at course web page to see how.
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:
CS100J CS100M is in Kimball Bll. Course Management System for CS100J is now populated with students who were pre-registered. Look at course web page to.
CS100J 11 September 2003 For more info: The "at" was made famous by Ray Tomlinson, a researcher at BBN in Boston.
1 CS100J 18 September 2007 More on Methods. Developing methods. Also: The inside-out rule; and the use of this and super. Read sec. 2.5 on stepwise refinement.
1 CS100J 20 September 2005 More on Methods. Developing methods Also: About the use of this and super Read section 2.5 on stepwise refinement Listen to.
1 CS100J 05 February 2005 Today’s topic: Customizing a class (continued) Quiz 1 is today Quiz 2 is next Tuesday Quote for the day: There is no reason anyone.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Quote for the day: Computational thinking: a fundamental skill for everyone … [It] is … choosing an appropriate representation for a problem or modeling.
Teaching OO to Beginners David Gries Computer Science, Cornell Past 3-4 years: Teach computing using Java students each semester Mostly Engineering,
UML Basics & Access Modifier
Inti Online Login Page (Lecturer/Student/Administrator View)
Quote for the day: Computational thinking: a fundamental skill for everyone … [It] is … choosing an appropriate representation for a problem or modeling.
1 CS Sept 2010 Customizing a class Quote for the day: I have traveled the length and breadth of this country and talked with the best people, and.
1 CS1110 Lecture Sept Developing (String-processing) programs; class Vector; wrapper classes Prelim: 7:30-9PM Thursday 7 October. Last name A-K:
Week 3 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CS100J 09 September 2003 Course Management System for CS100J is now populated with students who were pre-registered. Look at course web page to see how.
CS1110 lecture 5 14 Sept 2010 Testing; the class Object; toString; static variables & methods Reading for this lecture: Testing with JUnit (Appendix I.2.4.
A brief introduction to javadoc and doxygen Cont’d.
CPSC1301 Computer Science 1 Overview of Dr. Java.
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.
0 Teaching Java —with OO first David Gries Computer Science Cornell University Ithaca, NY
Lecture 131 CS110 Lecture 13 Thursday, March 11, 2004 Announcements –hw5 due tonight –Spring break next week –hw6 due two weeks from tonight Agenda –questions.
CS/ENGRD 2110 SPRING 2012 Lecture 2: Objects and classes in Java 1.
CS1110 lecture 5 8 Feb 2010 Testing; class Object; toString; static variables/methods Reading for this lecture: Testing with JUnit (Appendix I.2.4 & pp.
1 CS1110 lecture 4 9 Sept. Customizing a class & testing Classes: fields; getter & setter methods. Secs (p. 45) & 3.1 (pp. 105–110 only) Constructors.
1 CS1100 Fall Instructor: David Gries CS100M: Matlab No prior programming experience One semester of calculus Math & engineering type problems CS100J:
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
A brief introduction to doxygen. What does a compiler do?  A compiler ignores comments and processes the code.  What does doxygen do? –It ignores the.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
January 2006Colby College ITS Setting Up Course Pages.
1 CS100J 08 September 2005 Today’s topic: Customizing a class (continued) Quote for the day: There is no reason anyone would want a computer in their home.
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
1 CS1110. Lecture 2, 28 Jan Objects & classes PLive: Activities 3-3.1, 3-3.2, (not 3-3.3), 3-4.1, Summary of lectures: On course page,
CS/ENGRD 2110 SPRING 2016 Lecture 2: Objects and classes in Java 1.
1 CS100J 08 November 2005: Applications and Applets Java application; How to produce a stand-alone application, to be run without using DrJava or any such.
1 CS100J Spring Instructor: David Gries CS100M: Matlab No prior programming experience One semester of calculus Math & engineering type problems.
CS/ENGRD 2110 FALL 2013 Lecture 3: Fields, getters and setters, constructors, testing 1.
1 CS Sept 2010 Customizing a class Quote for the day: I have traveled the length and breadth of this country and talked with the best people, and.
Class Definitions and Writing Methods Chapter 3 3/31/16 & 4/4/16.
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.
CS/ENGRD 2110 Fall 2017 Lecture 2: Objects and classes in Java
CS Feb 2010 Customizing a class
Appendix A Barb Ericson Georgia Institute of Technology May 2006
CS1110 Spring Instructor: David Gries
CS100J. Lecture 2, 24 September Objects & classes
Java Programming: From Problem Analysis to Program Design,
Admin: Searching for a reservation Viewing the Trip Folder.
A brief introduction to doxygen
CS/ENGRD 2110 Spring 2018 Lecture 2: Objects and classes in Java
CS/ENGRD 2110 Fall2017 Lecture 4: The class hierarchy; static components
Admin: Searching for a reservation Viewing the Trip Folder.
CS 1110 Please do this now. Draw three variables on a piece of paper as shown to the right: b 4 c 7 d false Below is a “program” consisting of 3 assignment.
CS100J 06 September 2005 The class definition
CS/ENGRD 2110 Fall 2018 Lecture 2: Objects and classes in Java
CS/ENGRD 2110 Spring 2019 Lecture 2: Objects and classes in Java
Concepts for this lecture: Class Instance of a class, (an object)
CS100J CS100M is in Kimball Bll.
CS/ENGRD 2110 Spring 2019 Lecture 2: Objects and classes in Java
CS Feb 2011 Customizing a class
Workshop for Programming And Systems Management Teachers
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

1 CS100J 30 January 2007 The class definition Course Management System (CMS) for CS100J is populated with students who were pre-registered. Look at course web page to see how to get to it and what to do if you are not in it. Course web page has a link to it. You need to do this before we can register your iclicker in class. Today’s topic: Customizing a class. Quote for the day: I have traveled the length and breadth of this country and talked with the best people, and I can assure you that data processing is a fad that won't last out the year. --Editor in charge of business books for Prentice Hall, 1957

2 CS100J Reading for this lecture: Section 1.4 Read all the “style notes”, too, and the referenced PLive lectures (activities). Summary of lectures: On course home page, click on “Handouts” and then “Outline of lectures held so far”. Today: Your first class definition and method declaration. We will “customize” class JFrame to suit our needs. Introduce you to Javadoc (see top of page 378).

3 A class is a file-drawer. Contents: manila folders. Bill Patient name “B. Clinton” address “New York” owes $ getName() deposit(double d) (1)unique name on tab of manila folder. (2)manila folder, instance, object of the class (3)fields (variables) (4)methods (procedures and functions): instructions to do tasks and produce values.

4 Bill Patient name “B. Clinton” address “New York” owes $ getName() deposit(double d) x has value 6 y has value Bill y.getName() has the value “B.Clinton” y.deposit(250) ; will change the value of field owes to 0. x 6 y Bill int Patient

5 Class javax.swing.JFrame: an object is a window on your monitor. x j1 y j2 j1 JFrame setTitle(String) getTitle() getX() getY() setLocation(int,int) getWidth() getHeight() setSize(int,int) … new JFrame() Expression: create a new object of class JFrame and yield its name

6 Class definition: The java construct that describes the format of a folder (instance, object) of the class. /** description of what the class is for */ public class { } A class definition goes in its own file named. java On your hard drive, have a separate directory for each Java program that you write; put all the class definitions for the program in that directory. declarations of methods (in any order) This is a comment

7 Class definition: The java construct that describes the format of a folder (instance, object) of the class. /** description of what the class is for */ public class C { } declarations of methods (in any order) extends Class C has all the fields and methods that does, in addition to those declared in C. Class C inherits the fields and methods of.

8 /** description of what the class is for */ public class subclass-name extends superclass-name { declarations of methods } a0 super-class-name subclass-name methods and fields inherited from superclass-name methods declared in subclass-name folder belongs in file drawer for class subclass-name

9 /** description of what the class is for */ public class subclass-name extends superclass-name { /** Set the height of the window to the width */ public void setHeightToWidth() { } /** = the area of the window */ public int area() { } return getWidth() * getHeight(); First example of a procedure and of a function setSize(getWidth(), getWidth());

10 import javax.swing.*; /** An instance is a JFrame with methods to square it and to provide the area of the JFrame */ public class SquareJFrame extends JFrame { declarations of methods } folder belongs in file drawer for class SquareJFrame a0 SquareJFrame setHeightToWidth() area() setTitle(String) getTitle() getX() getY() setLocation(int,int) getWidth() getHeight() setSize(int,int) JFrame

11 import javax.swing.*; /** An instance is a JFrame with methods to square it and to provide the area of the JFrame */ public class SquareJFrame extends JFrame { /** = the area of the window */ public int area() { … } /** Set the height equal to the width */ public void setHeightToWidth() {…} } The class and every method in it has a comment of the form /** specification */ It is a Javadoc comment. Click on javadoc icon in DrJava to extract class specification. DO THIS AT LEAST ONCE IN LAB. Javadoc

12 About null var1 Bill var2 Hill var3 null Bill Patient Hill Patient Jill Patient null denotes the absence of a name. var3.getName() is a mistake!