1 For more info: CS1110 3 February 2009 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston.

Slides:



Advertisements
Similar presentations
Author 1 | Author 2 | Author 3 (edit this list on View > Master > Slide Master. In Office 2007 use View > Slide Master) Go to View > Master > Slide Master.
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.
CS/ENGRD 2110 SPRING 2015 Lecture 4: The class hierarchy; static components 1.
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;
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
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 CS100J Classes, stepwise refinement 25 February 2007 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht.
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.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
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.
CS 1110 Prelim I: Review Session. Exam Info Prelim 1: 7:30–9:00PM, Thursday, 6 October, Statler Auditorium Look at the previous Prelims Arrive early!
1 What’s a class People are confused with nested classes and anonymous classes. Experiments in a recitation last week revealed that the problems were probably.
CS100J 11 September 2003 For more info: The "at" was made famous by Ray Tomlinson, a researcher at BBN in Boston.
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.
Quote for the day: Computational thinking: a fundamental skill for everyone … [It] is … choosing an appropriate representation for a problem or modeling.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
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.
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.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
CS/ENGRD 2110 SPRING 2015 Lecture 6: Consequence of type, casting; function equals 1.
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 CS Sept 2010 Inside-out rule; use of this, super Developing methods (using Strings). Read sec. 2.5, stepwise refinement Listen to Plive, 2.5.1–2.5.4.
CS/ENGRD 2110 SPRING 2014 Lecture 4: The class hierarchy; static components 1.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
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.
CS/ENGRD 2110 FALL 2013 Lecture 4: The class hierarchy; static components 1.
1 CS100J Classes, stepwise refinement 14 Feb 2007 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr.
Lecture 121 CS110 Lecture 12 Tuesday, March 9, 2004 Announcements –hw5 due Thursday –Spring break next week Agenda –questions –ArrayList –TreeMap.
GoodOO Programming Practice in Java © Allan C. Milne v
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
1 CS2111 is no longer required for affiliation with Computer Science How to install newest Java Royal Flush is better than Full.
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 CS1110 Stepwise refinement, more on classes 24 Sep 2009 Application of String processing and stepwise refinement. Miscellaneous points about classes.
1 For more info: CS100J 7 February 2006 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston.
1 CS1110 Classes, stepwise refinement 17 Feb 2009 Miscellaneous points about classes. More on stepwise refinement. Next: wrapper classes. Section 5.1 of.
1 CS September 2008 Discussion of Methods: Executing method calls.If-statements. The return statement in a function. Local variables. For this and.
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,
1 CS1110 Classes, stepwise refinement 12 Feb 2009 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr.
1 Royal Flush is better than Full House CS March 31 Testing/Debugging. Also, about A6 Read chapter 14, pp. 385–401 Prelim 2 is Thursday eve, 14.
1 Royal Flush is better than Full House CS March 2009 Testing/Debugging Read chapter 14, pp. 385–401.
1 For more info: CS100J 08 February 2005 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston.
1 CS1110 Thursday, 10 Feb 2011 Discussion of Methods: Executing method calls. If-statements. The return statement in a function. Local variables. For this.
CS/ENGRD 2110 FALL 2013 Lecture 3: Fields, getters and setters, constructors, testing 1.
CS/ENGRD 2110 SPRING 2016 Lecture 4: The class hierarchy; static components 1.
1 CS Sep 2011 Miscellaneous points about classes. More on stepwise refinement. Next: wrapper classes. Section 5.1 of class text Need Help? Make.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
1 CS February 2009 Inside-out rule; use of this and super Developing methods (using String ops). Read sec. 2.5 on stepwise refinement Listen to.
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.
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
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.
1 CS1110 Classes, wrapper classes, Vectors. 10 Feb 2012 Miscellaneous points about classes. Discussion of wrapper classes and class Vector Use the text.
CS Feb 2010 Customizing a class
Lecture 10 Review of classes
This is an example of a short, informative split over two line
CS100J 21 February 2005 Casting About
CS1110 Classes, stepwise refinement 23 Sep 2009
CS100J Final Class on Classes 22 September 2005
Phil Tayco Slide version 1.0 Created Oct 2, 2017
This is an example of a short, informative split over two lines
Testing and debugging A short interlude 2-Dec-18.
Sit next to someone. Today, we do some work in pairs.
Sit next to someone. Today, we do some work in pairs.
Testing and debugging A short interlude 17-Apr-19.
CS100J Classes, stepwise refinement 21 September 2005
For more info: CS100J 13 September 2005 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston.
CS Feb 2011 Customizing a class
CS100J Final Class on Classes 10 February 2005
Presentation transcript:

1 For more info: CS February 2009 In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston to help develop the ARPANET, which later became the internet. In 1971, Ray Tomlinson of BBN was given the task of figuring out how to send files from one person to another. He created with file attachments. He as the separator between an name and location. Names in other languages: Italian: chiocciolina = little snail French: petit escargot = little snail German: klammeraffe = spider monkey Dutch: api = short for apestaart (monkey's tail) Finnish: miau = cat tail Israeli: strudel = a pastry Danish: snabel = an "A" with a trunk Spanish: un arroba = a unit of about 25 pounds Norwegian: kanel-bolle= spiral-shaped cinnamon cake

2 CS February 2009 TODAY: A bit more on testing. Object: the superest class of them all. pp Function toString. pp Static variables and methods. Sec. 1.5 (p. 47). NEXT LECTURE: Discussion of Methods Executing method calls. If-statements. The return statement in a function. Local variables. Reading for the next two lectures: Section 2, but NOT 2.3.8!!!!

3 Testing using Junit. Pages (through Sec ). Bug: Error in a program. Testing: Process of analyzing, running program, looking for bugs. Test case: A set of input values, together with the expected output. Debugging: Process of finding a bug and removing it. Get in the habit of writing test cases for a method based on its specification even before you write the method. In DrJava, use File item new Junit test case… to create a testing framework; it does some set-up for you. assertEquals(X,Y) is your friend.

4 /** = number of vowels in word w. Precondition: w contains at least one letter and no blanks or punctuation. */ public int numberOfVowels(String w) { // nothing here yet } Use test cases to clarify a specification (i.e., your ideas) first. Note: we sometimes notice more when in “critique mode”.

6 Class Object: The superest class of them all See 1/2-page section on page 154. The reason for this material will become clear later. You need this information to do assignment A2. Every class that does not extend another one automatically extends class Object (“the mother of all classes”). That is, public class C { … } is equivalent to public class C extends Object { …}

6 Class Object: The superest class of them all a1 Patient name Hopcroft address New York owes $ a1 Patient name Hopcroft address New York owes $ equals(Object) toString() So this… is really this. Object Because it is always there, to avoid clutter, we don’t generally draw the partition for superclass Object.

7 Method toString(): another useful debugging tool a1 Patient name Hopcroft address New York owes toString() $ equals(Object) toString() Object Convention: c.toString() returns a representation of folder c, giving info about the values in its fields. Put following method in Patient. /** = representation of this Patient */ public String toString() { return name + “ ” + address + “ ” + owes; } In appropriate places, the expression c automatically does c.toString()

8 Another example of toString() /** An instance represents a point (x, y) in the plane */ public class Point { private int x; // the x-coordinate private int y; // the y-coordinate /** Constructor: An instance for point (xx, yy) */ public Point(int xx, int yy) { } /** = a representation of this point in form “(x, y)” */ public String toString() { return ; } Getter and setter methods are not given on this slide Function toString should give the values in the fields in a format that makes sense for the class. Example: “(3, 5)” Fill these in

9 public class Chapter { private String title; // title of chapter private static int numberOfChapters= 0; // no. of Chapter objects created } a0 Chapter title “peace” a1 Chapter title “truth” numberOfChapters 2 File drawer for class Chapter A static field appears not in each folder, but as a single entity in the file drawer. It can be used to maintain information about multiple folders. Reference the variable by Chapter.numberOfChapters.

10 A static method is also in the drawer, not in individual folders. Make a method static if it doesn’t need to be in a folder because it wouldn’t reference the fields or methods of the “containing” folder. public class Chapter { private int number; // Number of chapter private static int numberOfChapters= 0; } /** = “b’s chapter num. is lower than c’s chapter num.”. Precondition: b and c are not null. */ public static boolean isLower(Chapter b, Chapter c) { return b.number < c.number; }