

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Historical background on the creation of email with file attachments by ray tomlinson in 1971 and introduces junit testing in java using a 'chapter' class. Information on testing using junit, creating test cases, and using the tostring() method. It also discusses static variables and methods.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


For more info: http://www.mailmsg.com/history.htm 1
In 1968, the Defense Department hired Bolt Beranek and Newman (BBN) of Boston to help develop the ARPANET, which later turned into 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 email with file attachments. He selected @ as the separator between an email name and location. 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) 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
5 /** A JUnit test case class.
/** Test first constructor and getter methods getTitle, getNumber, and getPrevious */ public void testFirstConstructor() { Chapter c1= new Chapter("one", 1, null); assertEquals("one”, c1.getTitle(), ); assertEquals(1, c1.getNumber()); assertEquals(null, c1.getPrevious()); } Every time you click button Test in DrJava, all methods with a name testXXX will be called.
/** Test Setter methods setTitle, setNumber, and setPrevious */ public void testSetters() { Chapter c1= new Chapter("one", 1, null ); c1.setTitle("new title"); c1.setNumber(18); Chapter c2= new Chapter("two", 2, null ); c1.setPrevious(c2); assertEquals("new title", c1.getTitle()); assertEquals(18, c1.getNumber()); assertEquals(c2, c1.getPrevious()); }
7
8
9
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; }
10
Getter and setter methods are not given on this slide
Example: “(3, 5)” Fill these in 11
public class Chapter { private String title; // title of chapter private static int numberChaps= 0; // no. of Chapter objects created } Reference static variable using Chapter.numberChaps
12
public class Chapter { private int number; // Number of chapter private static int numberOfChapters= 0; /** = “This chapter has a lower chapter number than Chapter c”. Precondition: c is not null. / public boolean isLowerThan(Chapter c) { return number < c.number; } } /* = “b’s chapter number is lower than c’s chapter number”. Precondition: b and c are not null. */ public static boolean isLower(Chapter b, Chapter c) { return b.number < c.number; }