1 / 13

CS100J 11 September 2003

CS100J 11 September 2003. The "at" sign, @, was made famous by Ray Tomlinson, a researcher at BBN in Boston. In 1971, he selected @ as the separator between an email name and location. Here are names for @ in other languages: Italian: *chiocciolina* = little snail

greena
Download Presentation

CS100J 11 September 2003

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS100J 11 September 2003 The "at" sign, @, was made famous by Ray Tomlinson, a researcher at BBN in Boston. In 1971, he selected @ as the separator between an email name and location. Here are names for @ in other languages: Italian: *chiocciolina* = little snail French: *petit escargot* = little snail German: *klammeraffe* = spider monkey Dutch: *api* = short for apestaart (monkey's tail) Norwegian: *kanel-bolle* = spiral-shaped cinnamon cake Danish: *snabel* = an "A" with a trunk Israeli: *strudel* = a pastry Finnish: *miau* = cat tail Spanish: *un arroba* = a unit of about 25 pounds For more info: http://www.mailmsg.com/history.htm

  2. How do you deal with the partner frame in FramingFrame? Explain through another example. public class Person { Date birthdate; String name; Address address; } A person has a mother. Suppose we want to include in each manilla folder of class Person the name on the folder of their mother. How do we do it?

  3. How do you deal with the partner frame in FramingFrame? Explain through another example. public class Person { private Date birthdate; private String name; private Address address; private Person mother; // = name of this person’s mother public Person getMother() { return mother; } } A person has a mother. Suppose we want to include in each manilla folder of class Person the name on the folder of their mother. Here’s how we do it.

  4. d2 Person p d1 name getName() name getName() Chelsea mother getMother() mother getMother() d2 public class Person { private String name; private Person mother; // = name of this person’s mother public Person getMother() { return mother; } // = name of this person’s name public String getName() { return name; } } d1 Person Hillary null To get the name of p’s mother: p.getMother().getName()

  5. d2 d1 Person Person s1 s8 p d1 name name s8 s1 String String mother mother d2 null Chelsea Hillary public class Person { private String name; private Person mother; // = name of this person’s mother public Person getMother() { return mother; } // = name of this person’s name public String getName() { return name; } }

  6. A Person has a mother.Therefore, a folder for a Person has a field, mother. Since a mother is a Person, the type of the field is Person. If the mother is not known, this field contains null.A folder of class FramingFrame is supposed to have an associated window, a JFrame, which surrounds it.Therefore, …

  7. m1 m2 m3 abs(int) abs(int) abs(int) Math Math Math Static variables public class Math { /** = the absolute value of x publicint abs(int x) { if (x >= 0) return x; return – x; } } Function abs belongs in every folder of class Math Need only ONE function abs

  8. m1 m2 m3 Math Math Math Four things in file drawer Math: abs(int) public class Math { /** = the absolute value of x publicstaticint abs(int x) { if (x >= 0) return x; return – x; } }

  9. m1 m2 m3 Math Math Math PI 3.14… Five things in file drawer Math: abs(int) public class Math { /** = the absolute value of x publicstaticint abs(int x) { if (x >= 0) return x; return – x; } // = 2* PI publicdouble twoPi() { return 2*PI; } public static final double PI= …; } means that PI can’t be changed

  10. m1 m2 m3 Math Math Math Five things in file drawer Math: Math is in package java.lang. PI 3.14… abs(int) Referencing static entities public class C { public void meth () { … // set x to absolute value of -3 x= Math.abs(-3); // set y to PI y= Math.PI; } }

  11. Methods: procedures, functions, constructorsRead: Section 2.1, 2.2 /** Print a, b, and their sum on one line */public static void print(int a, int b) { System.out.println(a + “ ” + b + “ ” + (a+b));} header Definition: a parameter is a variable that is declared within the parentheses of the method header. Parameters: a and b. The comment is a specification of the method. It says WHAT the method does. Method body: the “block” { … }

  12. Methods: procedures, functions, constructorsRead: Section 2.1, 2.2 /** Print a, b, and their sum on one line */public static void print(int a, int b) { …} header When writing or understanding a call on a method, look only at the specification and not the method body. What does this call do? print(3+4, 6); Print 3+4, 6, and their sum on one line. call, with arguments 3+4 and 6

  13. Methods: procedures, functions, constructorsRead: Section 2.1, 2.2 /** Print a, b, and their sum on one line */public static void print(int a, int b) { …} header When writing or understanding a call on a method, look only at the specification and not the method body. What does this call do? print(3+4, 6); Print 3+4, 6, and their sum on one line. Parameters of the method: a and b Arguments of the call: 3+4 and 6

More Related