CS100J 23 September 2003 Paradoxes. Is this sentence true or false: This sentence is false. In a small town, a barber cuts (only) the hair of all people.

Slides:



Advertisements
Similar presentations
Recursion.
Advertisements

JAVA Revision Lecture Electronic Voting System Marina De Vos.
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
CS 1031 Recursion (With applications to Searching and Sorting) Definition of a Recursion Simple Examples of Recursion Conditions for Recursion to Work.
Chapter 5: Abstraction, parameterization, and qualification Xinming (Simon) Ou CIS 505: Programming Languages Kansas State University Fall
Island of Knights and Knaves Jack says: “At least one of us is a knave.” Question: Is Jack a knight or knave? What about Jill? Answer: If Jack is a knave,
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
CS100J 18 September 2003 Rsrecah on spleilng Aoccdrnig to a rscheearch at Cmabirgde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are,
Loose endsCS-2301, B-Term “Loose Ends” CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd.
"Loose ends"CS-2301 D-term “Loose Ends” CS-2301 System Programming C-term 2009 (Slides include materials from The C Programming Language, 2 nd edition,
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.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Russell’s Paradox Lecture 24 Section 5.4 Fri, Mar 10, 2006.
Chapter 4 Procedural Methods. Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference.
1 Logical Assertions. 2 Logical assertions assertion: A statement that is either true or false. Examples: –Java was created in –The sky is purple.
CS1010E Programming Methodology Tutorial 4 Modular Programming with Functions C14,A15,D11,C08,C11,A02.
TABLES AND VALUES Section 1.5. Open Sentence Equation.
Defining Classes I Part A. Class definitions OOP is the dominant programming methodology in use today. OOP is the dominant programming methodology in.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
CS 100Lecture 191 CS100J Lecture 19 n Previous Lecture –Two dimensional arrays. –Reasonable size problem (a past assignment). –Stepwise refinement. –Use.
Russell’s Paradox and the Halting Problem Lecture 24 Section 5.4 Wed, Feb 23, 2005.
Encapsulation, Inheritance, Composition. Class Methods Can be either void or return Can have parameters or not Must be static Should be public Know how.
Review Creating Objects Pepper many references from rial/java/objects/object.html
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.
Creating and Using Class Methods. Definition Class Object.
Chapter 5 Methods 1. Motivations Method : groups statements that perform a function.  Level of abstraction (black box)  Code Reuse – no need to reinvent.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
1 Introduction to Computer Science for Majors II CPSC 233, Winter 2013 CPSC 233, winter 2013 Tutorial 7, Feb 6/7, 2013.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Exam Review 10/01/2014 Happy October. The Exam  Will be in Canvas  Two parts  Part A is recall – closed book, closed notes ◦Quizzes, in class activity.
Welcome to Software Engineering. Lecture 1 Metaphysics of Software Engineering Alex
1 CS1110 Thursday, 10 Feb 2011 Discussion of Methods: Executing method calls. If-statements. The return statement in a function. Local variables. For this.
COP 2220 Computer Science I Topics –Breaking Problems Down –Functions –User-defined Functions –Calling Functions –Variable Scope Lecture 4.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
1 CS Sep 2011 Miscellaneous points about classes. More on stepwise refinement. Next: wrapper classes. Section 5.1 of class text Need Help? Make.
Chapter 4: Types. Why Have Types? Detect simple kinds of errors: int square(int x) { return x*x; }... int bogus = square(“hello”); String bogus2 = square(3);
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
CS100J Lecture 19 Previous Lecture This Lecture
Chapter 5 Functions DDC 2133 Programming II.
Chapter 4 Procedural Methods.
Method Mark and Lyubo.
CSC 253 Lecture 8.
Building Java Programs
Building Java Programs
CSC 253 Lecture 8.
Chapter 4: Types.
Simple Classes in C# CSCI 293 September 12, 2005.
Classes & Objects: Examples
Building Java Programs
Logical assertions assertion: A statement that is either true or false. Examples: Java was created in The sky is purple. 23 is a prime number. 10.
Sit next to someone. Today, we do some work in pairs.
Chapter 9: Hypothesis Tests Based on a Single Sample
Unit 3 - The while Loop - Extending the Vic class - Examples
CS100J Lecture 8 Previous Lecture This Lecture Programming Concepts
Building Java Programs
Sit next to someone. Today, we do some work in pairs.
Simple Classes in Java CSCI 392 Classes – Part 1.
Chapter 7 Procedural Methods.
Building Java Programs
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Building Java Programs
Chapter 2 Sets Active Learning Lecture Slides
CS100J 22 February 2005 More on Methods. Developing methods
Methods (a.k.a functions)
Review for Midterm 3.
Functions That Do Not Return a Value
Presentation transcript:

CS100J 23 September 2003 Paradoxes. Is this sentence true or false: This sentence is false. In a small town, a barber cuts (only) the hair of all people who don’t cut their own hair. Who cuts the barber’s hair? If you try to fail and succeed, have you failed? Consider the set S of all sets that do not contain themselves. Does S contain itself? More on Methods. Scope of parameters. Functions versus procedures. The return statement in a function. Static vs non- static methods. Top-down design. Read section 2.3.

About using method specifications public class FramingFrame { private Jframe partner= new Jframe(); /** Create a partner at location … and with size … */ public void createPartner() { partner.setLocation(…); partner.setSize(…); } /** Set partner’s location, size as defined in createPartner */ public void reset Partner() { createPartner(); } } This is bad because (1)createPartner does not to what the spec says. (2) acc. to createPartner’s spec, resetPartner does more than it should.

Redoing the methods of previous slide public class FramingFrame { private Jframe partner; /** Create a partner at location … and with size … */ public void createPartner() { partner= new Jframe(); resetPartner(); } /** Set partner’s location, size as defined in createPartner */ public void resetPartner() { partner.setLocation(…); partner.setSize(…); } }

A function produces a result /** = smallest of b, c, d */ public static int smallest(int b, int, c, int d) { if (b <= c && b <= d) { return b; } // { The smallest is either c or d } if (c <= d) { return c; // { the smallest is d } return d; } Assertions

Top-down programming, stepwise refinement We developed a method to anglicize numbers (e.g. from 25 produce “twenty five”). using stepwise refinement. Pleae study section 2.5 on stepwise refinement.