Simple Java Eric Roberts CS 106A January 11, 2010.

Slides:



Advertisements
Similar presentations
How to Use This Presentation
Advertisements

Chapter 2—Programming by Example The Art and Science of An Introduction to Computer Science ERIC S. ROBERTS Java Programming by Example C H A P T E R 2.
Lecture 2 Internet Computing Using Java Theophano Mitsa UMASS-Dartmouth.
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Chapter 2 Programming by Example. A Holistic Perspective Three sections separated by blank lines. Program comment File: FileName.java
Classes and Objects Java programs are written as collections of classes, which serve as templates for individual objects. Each object is an instance of.
18.1 Finding Order in Diversity
Classification of Organisms Chapter 18 What is an Organism? An organism is generally referred to any living thing. More specifically any thing that has.
Until more recent times, scientists named Things with crazy long names that Just described the organism. Apis pubescens, thorace subgriseo, abdomine.
18.1 Finding Order in Diversity
Classification of Organisms. Categories of Biological Classification Scientists Assign Organisms Two-Word Names 2,000 yrs ago, Aristotle grouped plants.
Chapter 18 – Classification
18.1 Finding Order in Diversity By: Natalie Baumann.
Objectives 18.1 Finding Order in Diversity
Java Applets A First Program. Applet Example /* The world’s simplest program, repeated once more in another format in an attempt to turn all of you into.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
Chapter 3 - Introduction to Java Applets Outline 3.1Introduction 3.2Thinking About Objects 3.4A Simple Java Applet: Drawing a String 3.5Two More Simple.
TAXONOMY Presentation made by: sakura023. Need to Classify.
WHAT IS INHERITANCE? Java Unit 11: Inheritance I.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
SB3C. Examine the evolutionary basis of modern classification systems.
Understanding Classification Systems. Student Learning Objectives: 1. As a result of this lesson students will understand the purpose for classifying.
17.1 History of Classification
Classification and Taxonomy. THINK ABOUT IT –Scientists have been trying to identify, name, and find order in the diversity of life for a long time. The.
Classification and Taxonomy. THINK ABOUT IT –Scientists have been trying to identify, name, and find order in the diversity of life for a long time. The.
Introduction to Java and Object-Oriented Programming AJSS Computer Camp Department of Information Systems and Computer Science Ateneo de Manila University.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
What’s New in Computer Science Education? A Report on the 2005 ACM/SIGCSE Meeting.
Chapter 14 Table of Contents
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Principles of Taxonomy (chapter 18, page 446) Taxonomy is the science of classifying organisms based on their characteristics. Why is a system of classification.
The History of Classification Copyright © McGraw-Hill Education Early Systems of Classification Classification is the grouping of objects or organisms.
Classification.
Programming in Karel Eric Roberts CS 106A January 6, 2016.
History of Classification.
CLASSIFICATION Why Classify?. INQUIRY ACTIVITY 1) Construct a table with six rows and six columns. Label each row with the name of a different fruit.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
CLASSIFICATION OF ORGANISMS. Scientists assign organisms a two-word name. (Binomial nomenclature) ► The history of this started with Aristotle over 2,000.
Simple Java Eric Roberts CS 106A January 11, 2016.
Do Now 11/19 1.How is your closet organized? ( or how would your dream closet be organized?) 2. What criteria did you use to help organize your closet?
Intro to CLASSIFICATION Classification : A systematic arrangement into classes or groups → Can you name some things that you might classify in your everyday.
Chapter 18 Classification.
An Introduction to Classification November 29, 2010.
17.1 Classification Think about how things are grouped in a store or in your kitchen to help create order.
Classification Of Organisms Chapter 14 Coach Fults.
CS 112 Introduction to Programming Java Graphics Yang (Richard) Yang Computer Science Department Yale University 208A Watson, Phone:
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Will not cover Section 3.7 Thinking About Objects: Identifying.
Five-Minute Review 1.What steps do we distinguish in solving a problem by computer? 2.What are essential properties of an algorithm? 3.What is a definition.
Classification 1.  Evolution has lead to a large variety of organisms.  Biologists have identified and named about 1.5 million species so far.  They.
Programming – Lecture 15 Going Beyond the ACM Library.
Classification: Organizing Life’s Diversity Taxonomy, kingdom, phylum, class, order, family. Warm-up: 1.What is it called when natural selection leads.
Classification of Living Things
Five-Minute Review What steps do we distinguish in solving a problem by computer? What are essential properties of an algorithm? What is a definition of.
Lecture 09 Applets.
Strings and Graphics Jerry Cain CS 106J April 12, 2017.
Review.
SSEA Computer Science: CS106A
Section 1: The History of Classification
An Introduction to Classification
slides courtesy of Eric Roberts
Chapter 2—Programming by Example
SSEA Computer Science: Track A
Citation Map Visualizing citation data in the Web of Science
Graphics.
Classification.
Chapter 2—Programming by Example
Presentation transcript:

Simple Java Eric Roberts CS 106A January 11, 2010

Once upon a time...

The “Hello World” Program One of the important influences on the design of Java was the C programming language, which was developed at Bell Labs in the early 1970s. The primary reference manual for C was written by Brian Kernighan and Dennis Ritchie. On the first page of their book, the authors suggest that the first step in learning any language is to write a simple program that prints the message “hello, world” on the display. That advice remains sound today. 1.1 Getting Started The only way to learn a new programming language is to write programs in it. The first program to write is the same for all languages: Print the words hello, world This is the big hurdle; to leap over it you have to be able to create the program text somewhere, compile it, load it, run it, and find out where your output went. With these mechanical details mastered, everything else is comparatively easy. In C, the program to print “ hello, world ” is #include main() { printf("hello, world"); }

Simple Java

Evolution of Computer Languages

The 2002 ACM Turing Award Kristen NygaardOle Johan Dahl The most prestigious prize in computer science, the ACM Turing Award, was given in 2002 to two Norwegian computing pioneers, who developed the first object-oriented programming language in 1967.

Systems of Classification In the mid-18th century, the Scandinavian botanist Carl Linnaeus revolutionized the study of biology by developing a new system for classifying plants and animals in a way that revealed their structural relationships and paved the way for Darwin’s theory of evolution a century later. Carl Linnaeus (1707–1778) Linnaeus’s great contribution was to recognize that organisms fit into a hierarchical classification scheme in which the placement of individual species within the hierarchy reflects their anatomical similarities.

Biological Class Hierarchy CrustaceaArachnidaInsecta AnnelidaBrachiopodaMolluscaChordataArthropoda PlantsFungiAnimals Living Things Animals Arthropoda Insecta Hymenoptera Formicidae Iridomyrmex purpureus Kingdom Phylum Order Class Family Genus Species Classification of the red ant Iridomyrmex purpureus Every red ant is also an animal, an arthropod, and an insect, as well as the other superclasses in the chain.

Instances vs. Patterns Drawn after you, you pattern of all those. —William Shakespeare, Sonnet 98 In thinking about any classification scheme—biological or otherwise—it is important to draw a distinction between the category defined by a particular class and specific instances of that class. In the most recent example, the designation Iridomyrmex purpureus is not itself an ant, but rather a class of ant. There can be (and usually are) many ants, each of which is an individual of that class. Each of these fire ants is an instance of the general category encompassing all ants of its class. Each instance is of the species purpureus, the genus Iridomyrmex, the family Formicidae (which makes it an ant), and so on. Thus, each ant is not only an ant, but also an insect, an arthropod, and an animal.

The Program Hierarchy Applet JApplet Program DialogProgramGraphicsProgramConsoleProgram Java class hierarchies are similar to the biological class hierarchy from the previous slide. This diagram shows the hierarchy formed by the classes in the acm.program package. Every ConsoleProgram is also a Program, a JApplet, and an Applet. That means that every ConsoleProgram can run as an applet on the web. The same is true for every DialogProgram and GraphicsProgram.

import acm.program.*; public class HelloProgram extends ConsoleProgram { public void run() { println("hello, world"); } Hello World as a Console Program import acm.program.*; public class HelloProgram extends ConsoleProgram { public void run() { println("hello, world"); } HelloConsole hello, world

Hello World as a Dialog Program import acm.program.*; public class HelloProgram extends DialogProgram { public void run() { println("hello, world"); } import acm.program.*; public class HelloProgram extends DialogProgram { public void run() { println("hello, world"); }

Hello World as a Graphics Program import acm.graphics.*; import acm.program.*; public class HelloProgram extends GraphicsProgram { public void run() { add( new GLabel("hello, world", 100, 75) ); } HelloProgram hello, world import acm.graphics.*; import acm.program.*; public class HelloProgram extends GraphicsProgram { public void run() { add( new GLabel("hello, world", 100, 75) ); }

The Java Coordinate System Positions and distances in a graphics program are measured in terms of pixels, which are the individual dots that cover the screen. Unlike traditional mathematics, Java defines the origin of the coordinate system to be in the upper left corner. Values for the x coordinate increase as you move rightward across the screen; y coordinate values increase as you move downward. HelloProgram hello, world (100, 100) Creating a JLabel at a particular x and y position means that the baseline of the first character in the label appears at that point, as follows:

The End