CS1004: Intro to CS in Java, Spring 2005

Similar documents
CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University


Data Representation and Applets

Applets and the Graphics class

Data Representation and Applets

Data Representation and Applets

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Data Representation and Applets

Introduction to Computer Science I

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 9, Name: KEY

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name:

Graphics Applets. By Mr. Dave Clausen

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 7, Name:

Learning objectives: Objects and Primitive Data. Introduction to Objects. A Predefined Object. The print versus the println Methods

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A

Level 2: The Hardware World Chapters 4 and 5 (topics of other cs courses)

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

Arithmetic-logic units

CS1004: Intro to CS in Java, Spring 2005

Graphics Applets. By Mr. Dave Clausen

CS61C : Machine Structures

Chapter 3 - Introduction to Java Applets

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 26, Name: Key

COMP combinational logic 1 Jan. 18, 2016

This podcast will demonstrate a logical approach as to how a computer adds through logical gates.

CSC 220: Computer Organization Unit 10 Arithmetic-logic units

1 Getting started with Processing

Higher National Diploma in Information Technology First Year, Second Semester Examination 2015

Summary. 962 Chapter 23 Applets and Java Web Start

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets

Lab 3: Work with data (IV)

Lecture 10: Floating Point, Digital Design

Java - Applets. public class Buttons extends Applet implements ActionListener

Outline. policies. with some potential answers... MCS 260 Lecture 19 Introduction to Computer Science Jan Verschelde, 24 February 2016

CSC 101: Lab #5 Boolean Logic Practice Due Date: 5:00pm, day after lab session

Java Applet Basics. Life cycle of an applet:

Overview. Multiplexor. cs281: Introduction to Computer Systems Lab02 Basic Combinational Circuits: The Mux and the Adder

CprE 281: Digital Logic

CT 229 Arrays in Java

AYBUKE BUYUKCAYLI KORAY OZUYAR MUSTAFA SOYLU. Week 21/02/ /02/2007 Lecture Notes: ASCII

Chapter 12 Advanced GUIs and Graphics

Lecture Static Methods and Variables. Static Methods

Chapter 7 Applets. Answers

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 09 MULTIPLEXERS

Chapter 2: Universal Building Blocks. CS105: Great Insights in Computer Science

Chapter 2 Using Objects. Types. Number Literals. A type defines a set of values and the operations that can be carried out on the values Examples:

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet

Many ways to build logic out of MOSFETs

CS1004: Intro to CS in Java, Spring 2005

CS140 Lecture 03: The Machinery of Computation: Combinational Logic

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Standard Forms of Expression. Minterms and Maxterms

GUI, Events and Applets from Applications, Part III

Bits and Bytes. How do computers compute?

CS1004: Intro to CS in Java, Spring 2005

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Programming graphics

cs281: Introduction to Computer Systems Lab03 K-Map Simplification for an LED-based Circuit Decimal Input LED Result LED3 LED2 LED1 LED3 LED2 1, 2

1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4]

1.1 The Fifth Trial pages 18 and 25

Software Concepts. 2-8 Explain the process of translating and executing a Java program. How might the World Wide Web be involved?

CS1004: Intro to CS in Java, Spring 2005

Lecture 7 A First Graphic Program And Data Structures & Drawing

Rectangle Sums

Chapter 2 Exercise Solutions

COS 116 The Computational Universe Laboratory 8: Digital Logic II

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1

1 Getting started with Processing

Java Applet & its life Cycle. By Iqtidar Ali

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSC System Development with Java Introduction to Java Applets Budditha Hettige

Contents 8-1. Copyright (c) N. Afshartous

QUESTION BANK FOR TEST

SIMPLE APPLET PROGRAM

G51PRG: Introduction to Programming Second semester Applets and graphics

Outline. Announcements. Feedback. CS1007: Object Oriented Design and Programming in Java. Java beans Applets

Computer Organization and Levels of Abstraction

Java Programming Unit 6. Inner Classes. Intro to Apples. Installing Apache Tomcat Server.

CS/COE 0447 Example Problems for Exam 2 Spring 2011

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

Computer Organization and Levels of Abstraction

MODULE 5 - COMBINATIONAL LOGIC

Chapter Three. Digital Components

GC03 Boolean Algebra

Practice Midterm 1. Problem Points Score TOTAL 50

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

LAB #3: ADDERS and COMPARATORS using 3 types of Verilog Modeling

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

Appendix F: Java Graphics

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 6, Name:

Appendix F: Java Graphics

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

Software Engineering 2DA4. Slides 2: Introduction to Logic Circuits

Module 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Dr. Chuck Cartledge. 10 June 2015

EE292: Fundamentals of ECE

(Refer Slide Time 6:48)

Transcription:

CS4: Intro to CS in Java, Spring 25 Lecture #8: GUIs, logic design Janak J Parekh janak@cs.columbia.edu Administrivia HW#2 out New TAs, changed office hours How to create an Applet Your class must extend the Applet class This makes use of inheritance (Chapter 8) You don t t need to know how this works in order to write applets Next, embed the applet into an HTML file using a tag that references the class file of the applet View the HTML file using a web browser or appletviewer The web browser can automatically download the.class file like an image

HelloWorldApplet.java import javax.swing.japplet; import java.awt.*;.*; public class HelloWorldApplet extends JApplet { public void paint(graphics page) { page.drawstring( Hello world,,, ); } } HelloWorldApplet.html <html> <head><title>hello World!</title></head> <body> <applet code= HelloWorldApplet.class" width=6 height=4> </applet> </body> </html> Drawing Shapes The Graphics class has lots more primitives, including shape drawing Let s s look at the Java API again http://java.sun.com/j2se/.5./docs/api/java/awt/graphics.html Many shapes can be filled or unfilled The method parameters usually specify coordinates and sizes Shapes with curves, like an oval, are usually drawn by specifying the shape s bounding rectangle An arc can be thought of as a section of an oval Drawing a Line 5 X 2 45 Y page.drawline (, 2, 5, 45); or page.drawline (5, 45,, 2); 2

Drawing a Rectangle 5 X 2 4 Y page.drawrect (5, 2,, 4); Drawing an Oval 75 X 2 8 Y bounding rectangle 5 page.drawoval (75, 2, 5, 8); Drawing Shapes Every drawing surface has a background color Your applet is one surface; for multiple backgrounds, use filled rectangles Every graphics context has a current foreground color Which you can change as the program goes on; like picking up a different crayon setbackground( ) ) and page.setcolor( ) Let s s look at the book s s applet (page 3) 3

Segue Back to computer hardware basics We ll pick up with more Java next time The stuff we covered up until now is what you need for HW#2 Boolean Logic Apart from storage, what does a computer do? Low-level manipulations consist of boolean logic i.e., operations on true/false values True/false maps easily onto bistable environment Boolean logic operations on electronic signals may be built out of transistors and other electronic devices Goal: build computing logic out of these Imagine a simple elevator controller Boolean operations a AND b True only when a is true and b is true a OR b True when either a is true or b is true, or both are true English or is not OR (it s s XOR) NOT a True when a is false, and vice versa And every more complex operation is built out of these three 4

Boolean Logic (continued) Boolean expressions Constructed by combining together Boolean operations (a AND b) OR ((NOT b) AND (NOT a)) Truth tables capture the output/value of a Boolean expression A column for each input plus the output A row for each combination of input values Boolean Logic (continued) Example: (a AND b) OR ((NOT b) and (NOT a)) a b Value Gates Gates Since logic so common, we design hardware to do this AND gate Two input lines, one output line Outputs a when both inputs are OR gate Two input lines, one output line Outputs a when either input is NOT gate One input line, one output line Outputs a when input is and vice versa 5

The Three Basic Gates and Their Symbols (see pages 56-57 57 for implementation) Big picture Abstraction in hardware design Map hardware devices to Boolean logic Design more complex devices in terms of logic,, not electronics Conversion from logic to hardware design may be automated A circuit is a realized collection of logic gates Transforms a set of binary inputs into a set of binary outputs Values of the outputs depend only on the current values of the inputs Diagram of a Typical Computer Circuit 6

A Circuit Construction Algorithm Sum-of of-products algorithm Truth table captures every input/output possible for circuit Repeat process for each output line Build a Boolean expression using AND and NOT for each of the output line Combine together all the expressions with ORs Build circuit from whole Boolean expression Two major kinds of circuits Computation circuits Take two bits of data and combine them in some fashion Control circuits Determine which computation circuits or data bits to use A few examples of computation circuits -bit equality Two inputs, one output n-bit equality Composed of many -bit equality circuits ANDed together -bit adder Three inputs, two outputs n-bit adder Composed of many -bit adders chained together Let s s do these on the board Pages 65-72 72 7

Next time Continue computer architecture Start Java OO concepts 8