CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY

Size: px
Start display at page:

Download "CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY"

Transcription

1 CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY PROFESSOR GODFREY MUGANDA 1. Multi-Threaded Network Photo Server You are going to write a system that allows users to store photos on a servers. The project is loosely modelled after the operation of the Internet s FTP protocol. The server is a TCP multi-threaded server that functions as a network-based photo repository. A client connecting to the server must first register, or, if previously registered, must log in. Upon registration of a new user, the server creates a directory or folder for that user. All photos uploaded by the user will be stored in the directory assigned to that user. The server rejects a new registration if a person tries to register with a name that is already taken. Here is a list of protocol messages sent from the client to the server, followed by the server s response, if any. (1) register name. The client wants to register a new account under the given name. The parameter name is a string with the same syntax as a Java identifier. Upon receipt of this message, the server creates a folder with the given name if the folder does not already exist, and returns the string Ok: name registered to the client. If a folder of the same name already exists, the server returns the string Failure: name already in use to the client. A newly registered user is considered to be automatically logged in. (2) login name. The client wants to log in as the specified user. If there is no registered user by that name, the server returns the message Failure: unregistered user name to the client. Otherwise, the client gets logged in and the server returns the message Ok to the client. The server will reply with a Failure: not logged in message to any message that is received before the user has logged in. (3) logout. The client is done using the server. At the receipt of this message, the server closes the connection and de-allocates resources being used to maintain client-state information. (4) list. The client wants a list of names of all files previously stored by the logged-in user. 1

2 2 PROFESSOR GODFREY MUGANDA Upon receipt of this message, the server sends back a message consisting of n + 1 lines, where n is the number of files currently stored in the user s folder. The first line will be the number n. This line will be followed by n lines, with each line containing the name of a file. (5) store filename. The client wants to store a file of that name in the directory associated with the logged-in user. Upon receipt of this message the server will check to see if a file of that name already exists in the user s directory. If such a file exists, the server returns a message Failure: file already exists. Otherwise, the server returns a message of Ok: send file and moves into a state where it is expecting a connect store port message from the client. (6) connect store port. The client will only send this message after it has received an Ok: send file message from the server. Immediately after sending this message, the client sets up a server socket at the specified port to wait for a data connection request from the server. After a data connection request has been accepted, the client sends the contents of the file through the data connection and shuts down the output stream of the data connection. The server should only receive this message after it has sent an Ok: send file to the client. Upon receipt of this message, the server opens a data connection to the client at the specified port, reads the data stream, and stores the contents into a file of the specified name in the directory associated with the logged-in user. The server then sends an Ok: file stored message to the client. Upon receipt of this message, the client closes the active and passive sockets associated with the data connection. (7) retrieve filename. The client wants to retrieve a file of that name from the directory associated with the logged-in user. Upon receipt of this message the server will check to see if a file of that name exists in the user s directory. If such a file does not exists the server returns a message Failure: file does not exist. Otherwise, the server returns a message of Ok: receive file and moves into a state where it is expecting a connect retrieve port message from the client. (8) connect retrieve port. The client will only send this message after it has received an Ok: retrieve file message from the server. Immediately after sending this message, the client sets up a server socket at the specified port to wait for a data connection request from the server. After a data connection request has been accepted, the client reads the contents of the file the data connection and processes them. The client then sends a Ok: file retrieved

3 CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY 3 message to the server, and closes two sockets associated with the data connection. The server should only receive this message after it has sent an Ok: retrieve file to the client. Upon receipt of this message, the server opens a data connection to the client at the specified port and copies the contents of the file into the output stream of the data connection. The server then shuts down the output stream. At this point, the server waits for an Ok: file retrieved message from the client, and then closes its data socket. 2. What to do with unknown commands If the server receives any other command, it will return an message Failure: unknown command to the client and close the connection. 3. The Client User Interface Next we need to specify the user interface on the user agent, that is, the application that interfaces with the user and runs the client-side protocol. When starting up, the user agent asks the user to enter the IP address of the server. (The server will be running at the usual port number of 50000). The client then connects to the server. The user can enter the following commands at the command line: (1) register name. The client will read the command and forward it to the server. The client then reads the server s response and displays it. (2) login name. The client forwards the command to the server. The client then reads the server s response and displays it. (3) list. The client will forward the command to the server and display the server s response. (4) get filename. The client will send a corresponding retrieve filename to the server. The client then reads the server s response and displays it. If the server s response was Ok, the client reads the file sent by the server and displays the image to the user. Details of how this is done are given later. (5) put filename. The user agent will pop up a JFileChooser dialog to allow the user to navigate the local file system and select a file. The client will then send a corresponding store filename to the server. If everything goes OK and the specified file name does not already exist in the user s folder on the server, the client sends the contents of the file selected by the user using the file chooser. Notice the file selected with the file chooser does not have to have the name specified by the user. However, it will be stored on the server under the name specified by the user.

4 4 PROFESSOR GODFREY MUGANDA 4. Working With Images You will need to display images that are received from the server. To do this, you need to know how to work with images. Here is an example program that works with images. It uses a JFileChooser to allow the user to select a file that contains an image from the local file system. The program also uses the read method of the ImageIO class to read the image from the file and return an Image object, and it uses the drawimage method of the Graphics object to draw an image on the surface of a JPanel object. To understand how images display works, you need to know that every Java user interface component has a void paintcomponent(graphics g) that is automatically called by the runtime system to draw the image and /or text that is to appear on the component whenever that component need to be displayed. If you want to draw an image on a component, you need to subclass the component and override the paintcomponent method to draw what you want. We do this in the ImagePanel class. We need to set the size of the panel showing the image to the pixel dimensions of the image. This is done by calling the getwidth and getheight methods of the image. We use the width and height to create a Dimension object which is in turn used to set the preferred size of the image panel to the exact dimensions of the image. We need a top level component to display the image panel. For this, we use a JDialog object. We define a subclass of JDialog that takes an image panel to display, and a title to display along with the image, and adds it to the dialog. When the dialog is made visible, the paintcomponent method of the enclosed image panel will be called, and that method will draw the image. package imagedemo; import java.awt.dimension; import java.awt.graphics; import java.awt.image; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.io.file; import java.io.ioexception; import javax.imageio.imageio; import javax.swing.jdialog; import javax.swing.jfilechooser; import javax.swing.jpanel; public class ImageDemo public static void main(string[] args) throws IOException // Ask user for the name of a file that contains an image JFileChooser inputchooser = new JFileChooser(); int result = inputchooser.showopendialog(null); if (result!= JFileChooser.APPROVE_OPTION)

5 CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY 5 System.out.println("You did not select a file. " + "Program is ending."); System.exit(1); File inputfile = inputchooser.getselectedfile(); // Read the image in the file Image myimage = ImageIO.read(inputFile); // Create a panel that displays the image ImagePanel imagepanel = new ImagePanel(myImage); // Create an ImageDialog to display the image JDialog imagedialog = new ImageDialog(imagePanel, "Pretty Little Flowers"); // Show the image dialog imagedialog.setvisible(true); // Exit the program System.exit(0); /** * This class defines a panel that displays an image Administrator */ class ImagePanel extends JPanel private Image image; public ImagePanel(Image image) this.image = image; // get size of image and use it to set preferred size of panel int width = image.getwidth(this); int height = image.getheight(this); this.setpreferredsize(new Dimension(width, public void paintcomponent(graphics g) g.drawimage(image, 0, 0, this); /** * This class is a dialog for displaying a panel that has an image Administrator */ class ImageDialog extends JDialog

6 6 PROFESSOR GODFREY MUGANDA public ImageDialog(ImagePanel imagepanel, String title) // Make the dialog modal and set title this.setmodal(true); this.settitle(title); // Add the image panel and pack the size of the dialog this.add(imagepanel); this.pack(); // Make invisible when it is closed this.setdefaultcloseoperation(jdialog.hide_on_close); 5. Working With Directories and Files This section shows you how to work with files and directories. You need some knowledge of the Java File class. Look up the Java 7 documentation on this class. Some of the methods of this class you will need are File [] listfiles boolean mkdir() boolean isfile() boolean isdirectory() boolean exists() Path topath() You should also look at the constructors for the File class. You should also look at the Files class in the package java.nio. The Files class is new with Java 7. It offers some copy methods that provide very efficient means of copying an entire file to an output stream, (You can use this when the client is sending a file to the server) and an efficient means of copying an output stream to a file (You can use this when the server is receiving a file from the client). Here is an example. package directoriesprogram; import java.io.bytearrayinputstream; import java.io.bytearrayoutputstream; import java.io.file; import java.io.ioexception; import java.nio.file.files; import java.nio.file.path; import java.util.arrays; public class DirectoriesProgram public static void main(string[] args) throws IOException File dir = new File("c:/temp"); // List the contents of the director

7 CSC 569 WINTER 13 GRADUATE PROJECT: NETWORK-BASED IMAGE REPOSITORY 7 if (dir.isdirectory()) System.out.println("Directory " + dir + " has contents: "); System.out.println(Arrays.toString(dir.listFiles())); else System.out.println(dir + "is not a directory."); // Create two directories in the directory dir String [] subdirs = "Alan", "Beth"; for (String d : subdirs) File newdir = new File(dir, d); newdir.mkdir(); // List all the contents of dir System.out.println("Contents of " + dir + " are: "); System.out.println(Arrays.toString(dir.listFiles())); // The following code shows how to copy the content of an inputstream // into a target file. First you create an File object that represents // the target file, then you get a Path object that represents the // target file from the File object. Then you use the Files.copy // method to copy the contents of the input stream into the target file. // We use a ByteArrayInputStream for the input stream here, but you // could use a TCP socket input stream. Note that you cannot use an // existing file for the target file. If you run this more than once, // Delete the c:/temp/alan/file1.data file before running again. // Create a path name for a file1.data in the subdirectory Alan File parent = new File(dir, "Alan"); File datafile = new File(parent, "file1.data"); // Get a Path object to represent the file file1.data Path file1path = datafile.topath(); // Create a byte array input stream that has data to write to file1.data ByteArrayInputStream byteinstream = new ByteArrayInputStream("Hello".getBytes()); // Copy the byte array input stream to the file Files.copy(byteInStream, file1path); // The following code shows how to copy a source file into an output stream. // You can use this to copy a file into the output stream of a TCP socket. // Here we just use a ByteArrayOutputStream // Create a File object for the source file, and then get the Path // object from the File object. Here we already have the Path object // file1path, so we just use that. // Create a ByteArrayOutputStream

8 8 PROFESSOR GODFREY MUGANDA ByteArrayOutputStream byteoutstream = new ByteArrayOutputStream(); // Use Files.copy to copy the source file into the target output stream Files.copy(file1Path, byteoutstream); // Convert the bytes in the ByteOutputStream to String and display System.out.println(byteOutStream.toString()); This is due Friday of Week 10.

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

CS11 Java. Fall Lecture 4

CS11 Java. Fall Lecture 4 CS11 Java Fall 2014-2015 Lecture 4 Java File Objects! Java represents files with java.io.file class " Can represent either absolute or relative paths! Absolute paths start at the root directory of the

More information

Image Java Foundation Classes (JFC) java.awt.image JFC. Image. Image. Image PNG GIF JPEG

Image Java Foundation Classes (JFC) java.awt.image JFC. Image. Image. Image PNG GIF JPEG 11 2013 6 25 11.1.............................. 11 1 11.2.............................. 11 2 11.3................................... 11 5 11.4.............................. 11 6 11.5.......................................

More information

JDirectoryChooser Documentation

JDirectoryChooser Documentation JDirectoryChooser Documentation Page 1 of 7 How to Use JDirectoryChooser The JDirectoryChooser provides user-friendly GUI for manipulating directories from Java application. User can either simply choose

More information

RenWeb Handout Manual

RenWeb Handout Manual RenWeb Handout Manual Tiffany Gurgel October 2013 RenWeb Handout Manual Table of Contents Pre-Training Handout: Creating a Document as a PDF 2 Handout 1A: Adding Homework & Web Document 4 Handout 2A: Creating

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11. Problem 1. Finding the Median (15%)

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11. Problem 1. Finding the Median (15%) 1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11 Problem 1. Finding the Median (15%) Write a method that takes in an integer array and returns an

More information

JAVA - FILE CLASS. The File object represents the actual file/directory on the disk. Below given is the list of constructors to create a File object

JAVA - FILE CLASS. The File object represents the actual file/directory on the disk. Below given is the list of constructors to create a File object http://www.tutorialspoint.com/java/java_file_class.htm JAVA - FILE CLASS Copyright tutorialspoint.com Java File class represents the files and directory pathnames in an abstract manner. This class is used

More information

CSCI 201L Midterm Written SOLUTION Fall % of course grade

CSCI 201L Midterm Written SOLUTION Fall % of course grade CSCI 201L Midterm Written SOLUTION Fall 2015 10% of course grade 1. Inheritance Answer the following questions about inheritance. a. Does Java allow overloading, overriding, and redefining of methods?

More information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student

More information

6.092 Introduction to Software Engineering in Java January (IAP) 2009

6.092 Introduction to Software Engineering in Java January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.092 Introduction to Software Engineering in Java January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

Final Examination Semester 2 / Year 2012

Final Examination Semester 2 / Year 2012 Final Examination Semester 2 / Year 2012 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates:

More information

STREAMS. (fluxos) Objetivos

STREAMS. (fluxos) Objetivos STREAMS (fluxos) Objetivos To be able to read and write files To become familiar with the concepts of text and binary files To be able to read and write objects using serialization To be able to process

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

More information

Here is a hierarchy of classes to deal with Input and Output streams.

Here is a hierarchy of classes to deal with Input and Output streams. PART 25 25. Files and I/O 25.1 Reading and Writing Files A stream can be defined as a sequence of data. The InputStream is used to read data from a source and the OutputStream is used for writing data

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101.

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101. Creating and running a Java program. This tutorial is an introduction to running a computer program written in the computer programming language Java using the BlueJ IDE (Integrated Development Environment).

More information

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING PROFESSOR GODFREY MUGANDA 1. Learn to Generate Random Numbers The class Random in Java can be used to create objects of the class

More information

!"# $ %&# %####' #&() % # # # #&* # ## +, # -

!# $ %&# %####' #&() % # # # #&* # ## +, # - By Pep Jorge @joseplluisjorge Steema Software July 213!"# $ %&# %####' #&() % # # # #&* # ## +, # -. / " - $- * 11 1 1$ 2 11 1 3 4 / $ 5 5,+67 +68$ Copyright 213 Steema Software SL. Copyright Information.

More information

AP CS Unit 12: Drawing and Mouse Events

AP CS Unit 12: Drawing and Mouse Events AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.

More information

Grid4All Security User's Manual, Release 0.6

Grid4All Security User's Manual, Release 0.6 Grid4All Security User's Manual, Release 0.6 by Leif Lindbäck and Vladimir Vlassov Royal Institute of Technology (KTH), Stockholm, Sweden Email {leifl, vladv}@kth.se FP6 Project Grid4All (IST-2006-034567)

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Lecture 23. Java File Handling. Dr. Martin O Connor CA166

Lecture 23. Java File Handling. Dr. Martin O Connor CA166 Lecture 23 Java File Handling Dr. Martin O Connor CA166 www.computing.dcu.ie/~moconnor Topics File Systems What is a path? Symbolic links How to create a file How to obtain the file path from a file How

More information

QRG: Adding Images, Files and Links in the WYSIWYG Editor

QRG: Adding Images, Files and Links in the WYSIWYG Editor QRG: Adding Images, Files and Links in the WYSIWYG Editor QRG: Adding Images, Files and Links in the WYSIWYG Editor... 1 Image Optimisation for Web use:... 2 Add an Image... 2 Linking to a File... 4 Adding

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

More information

COMP200 INPUT/OUTPUT. OOP using Java, based on slides by Shayan Javed

COMP200 INPUT/OUTPUT. OOP using Java, based on slides by Shayan Javed 1 1 COMP200 INPUT/OUTPUT OOP using Java, based on slides by Shayan Javed Input/Output (IO) 2 3 I/O So far we have looked at modeling classes 4 I/O So far we have looked at modeling classes Not much in

More information

Lecture 02, Fall 2018 Friday September 7

Lecture 02, Fall 2018 Friday September 7 Anatomy of a class Oliver W. Layton CS231: Data Structures and Algorithms Lecture 02, Fall 2018 Friday September 7 Follow-up Python is also cross-platform. What s the advantage of Java? It s true: Python

More information

CS 251 Intermediate Programming GUIs: Components and Layout

CS 251 Intermediate Programming GUIs: Components and Layout CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()

More information

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Introduction This assignment will ask that you write a simple graphical user interface (GUI). Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction

More information

ASSIGNMENT 5 Objects, Files, and More Garage Management

ASSIGNMENT 5 Objects, Files, and More Garage Management ASSIGNMENT 5 Objects, Files, and More Garage Management COMP-202B, Winter 2010, All Sections Due: Wednesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified,

More information

Course: CMPT 101/104 E.100 Thursday, November 23, 2000

Course: CMPT 101/104 E.100 Thursday, November 23, 2000 Course: CMPT 101/104 E.100 Thursday, November 23, 2000 Lecture Overview: Week 12 Announcements Assignment 6 Expectations Understand Events and the Java Event Model Event Handlers Get mouse and text input

More information

Software 1 with Java. Recitation No. 9 (Java IO) December 10,

Software 1 with Java. Recitation No. 9 (Java IO) December 10, Software 1 with Java Recitation No. 9 (Java IO) December 10, 2006 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

CSCI 201L Midterm Written Fall % of course grade

CSCI 201L Midterm Written Fall % of course grade CSCI 201L Midterm Written Fall 2015 10% of course grade 1. Inheritance Answer the following questions about inheritance. a. Does Java allow overloading, overriding, and redefining of methods? (0.5%) b.

More information

GUI Event Handlers (Part II)

GUI Event Handlers (Part II) GUI Event Handlers (Part II) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda Listener

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented

More information

CSE wi Final Exam 3/12/18. Name UW ID#

CSE wi Final Exam 3/12/18. Name UW ID# Name UW ID# There are 13 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for

More information

CSE143 - Project 3A Turn-in Receipt

CSE143 - Project 3A Turn-in Receipt 1 of 9 11/24/2003 4:24 PM CSE143 - Project 3A Turn-in Receipt Prins, Ryan Michael (rprins@u.washington.edu) Section AD Daniel Wyatt Turn-in logged at 16:24:36 PST, Monday, Nov 24, 2003 Your program compiled

More information

CS5233 Components Models and Engineering

CS5233 Components Models and Engineering Prof. Dr. Th. Letschert CS5233 Components Models and Engineering - Komponententechnologien Master of Science (Informatik) Working with Jars (and other files using NIO) Seite 1 Jars http://download.oracle.com/javase/tutorial/deployment/jar/index.html

More information

CSC 231 DYNAMIC PROGRAMMING HOMEWORK Find the optimal order, and its optimal cost, for evaluating the products A 1 A 2 A 3 A 4

CSC 231 DYNAMIC PROGRAMMING HOMEWORK Find the optimal order, and its optimal cost, for evaluating the products A 1 A 2 A 3 A 4 CSC 231 DYNAMIC PROGRAMMING HOMEWORK 10-1 PROFESSOR GODFREY MUGANDA 1. Find the optimal order, and its optimal cost, for evaluating the products where A 1 A 2 A 3 A 4 A 1 is 10 4 A 2 is 4 5 A 3 is 5 20

More information

Generating Charts in PDF Format with JFreeChart and itext

Generating Charts in PDF Format with JFreeChart and itext Generating Charts in PDF Format with JFreeChart and itext Written by David Gilbert May 28, 2002 c 2002, Simba Management Limited. All rights reserved. Everyone is permitted to copy and distribute verbatim

More information

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO)

Basic I/O - Stream. Java.io (stream based IO) Java.nio(Buffer and channel-based IO) I/O and Scannar Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 I/O operations Three steps:

More information

Security Management System Configuring Secondary Storage Access from CMS

Security Management System Configuring Secondary Storage Access from CMS Security Management System Configuring Secondary Storage Access from CMS Introduction Security management system server software supports secondary recording feature, in which the camera streams are recorded

More information

CSE wi Final Exam 3/12/18 Sample Solution

CSE wi Final Exam 3/12/18 Sample Solution Question 1. (8 points, 2 each) Equality. Recall that there are several different notions of object equality that we ve encountered this quarter. In particular, we have the following three: Reference equality:

More information

Graphic User Interfaces. - GUI concepts - Swing - AWT

Graphic User Interfaces. - GUI concepts - Swing - AWT Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations

More information

public static void main(string[] args) { GTest mywindow = new GTest(); // Title This program creates the following window and makes it visible:

public static void main(string[] args) { GTest mywindow = new GTest(); // Title This program creates the following window and makes it visible: Basics of Drawing Lines, Shapes, Reading Images To draw some simple graphics, we first need to create a window. The easiest way to do this in the current version of Java is to create a JFrame object which

More information

Advanced Java Programming. Networking

Advanced Java Programming. Networking Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol

More information

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance? CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look

More information

Building Graphical User Interfaces. GUI Principles

Building Graphical User Interfaces. GUI Principles Building Graphical User Interfaces 4.1 GUI Principles Components: GUI building blocks Buttons, menus, sliders, etc. Layout: arranging components to form a usable GUI Using layout managers. Events: reacting

More information

Fundamentals of Object Oriented Programming

Fundamentals of Object Oriented Programming INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of

More information

The AWT Package, Graphics- Introduction to Images

The AWT Package, Graphics- Introduction to Images Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, Graphics- Introduction to Images Java Programming, Lecture Notes # 170, Revised 09/23/98.

More information

Software 1 with Java. Recitation No. 7 (Java IO) May 29,

Software 1 with Java. Recitation No. 7 (Java IO) May 29, Software 1 with Java Recitation No. 7 (Java IO) May 29, 2007 1 The java.io package The java.io package provides: Classes for reading input Classes for writing output Classes for manipulating files Classes

More information

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20 File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source

More information

Control Statements: Part Pearson Education, Inc. All rights reserved.

Control Statements: Part Pearson Education, Inc. All rights reserved. 1 5 Control Statements: Part 2 5.2 Essentials of Counter-Controlled Repetition 2 Counter-controlled repetition requires: Control variable (loop counter) Initial value of the control variable Increment/decrement

More information

CSPP : Introduction to Object-Oriented Programming

CSPP : Introduction to Object-Oriented Programming CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text

More information

CS Programming I: File Input / Output

CS Programming I: File Input / Output CS 200 - Programming I: File Input / Output Marc Renault Department of Computer Sciences University of Wisconsin Madison Spring 2018 TopHat Sec 3 (AM) Join Code: 427811 TopHat Sec 4 (PM) Join Code: 165455

More information

Internet Technology 2/7/2013

Internet Technology 2/7/2013 Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server

More information

RenWeb Training. Creating Your Classroom Website

RenWeb Training. Creating Your Classroom Website RenWeb Training Creating Your Classroom Website October 2013 RenWeb Training Manual Table of Contents Ren Web Survey 3 Pre-Training Handout: Saving a Document as a PDF 4 Lesson 1: Adding Homework & Web

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

CS Programming I: File Input / Output

CS Programming I: File Input / Output CS 200 - Programming I: File Input / Output Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624

More information

2. (True/False) All methods in an interface must be declared public.

2. (True/False) All methods in an interface must be declared public. Object and Classes 1. Create a class Rectangle that represents a rectangular region of the plane. A rectangle should be described using four integers: two represent the coordinates of the upper left corner

More information

Here is a hierarchy of classes to deal with Input and Output streams.

Here is a hierarchy of classes to deal with Input and Output streams. PART 15 15. Files and I/O 15.1 Reading and Writing Files A stream can be defined as a sequence of data. The InputStream is used to read data from a source and the OutputStream is used for writing data

More information

Introduction to the JAVA UI classes Advanced HCI IAT351

Introduction to the JAVA UI classes Advanced HCI IAT351 Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Published: December 23, 2013, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information

Certified Core Java Developer VS-1036

Certified Core Java Developer VS-1036 VS-1036 1. LANGUAGE FUNDAMENTALS The Java language's programming paradigm is implementation and improvement of Object Oriented Programming (OOP) concepts. The Java language has its own rules, syntax, structure

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: September 17, 2012, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information

CSC 355 PROJECT 4 NETWORKED TIC TAC TOE WITH WPF INTERFACE

CSC 355 PROJECT 4 NETWORKED TIC TAC TOE WITH WPF INTERFACE CSC 355 PROJECT 4 NETWORKED TIC TAC TOE WITH WPF INTERFACE GODFREY MUGANDA In this project, you will write a networked application for playing Tic Tac Toe. The application will use the.net socket classes

More information

Chapter 21- Using Generics Case Study: Geometric Bunch. Class: Driver. package csu.matos; import java.util.arraylist; public class Driver {

Chapter 21- Using Generics Case Study: Geometric Bunch. Class: Driver. package csu.matos; import java.util.arraylist; public class Driver { Chapter 21- Using Generics Case Study: Geometric Bunch In this example a class called GeometricBunch is made to wrap around a list of GeometricObjects. Circle and Rectangle are subclasses of GeometricObject.

More information

*** TROUBLESHOOTING TIP ***

*** TROUBLESHOOTING TIP *** *** TROUBLESHOOTING TIP *** If you are experiencing errors with your deliverable 2 setup which deliverable 3 is built upon, delete the deliverable 2 project within Eclipse, and delete the non working newbas

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: November 8, 2010, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information

Chapter 6: Inheritance

Chapter 6: Inheritance Chapter 6: Inheritance EECS 1030 moodle.yorku.ca State of an object final int WIDTH = 3; final int HEIGTH = 4; final int WEIGHT = 80; GoldenRectangle rectangle = new GoldenRectangle(WIDTH, HEIGHT, WEIGHT);

More information

Topic 12 Introduction to Recursion. "To a man with a hammer, everything looks like a nail" -Mark Twain

Topic 12 Introduction to Recursion. To a man with a hammer, everything looks like a nail -Mark Twain Topic 12 Introduction to Recursion "To a man with a hammer, everything looks like a nail" -Mark Twain Underneath the Hood. The Program Stack When you invoke a method in your code what happens when that

More information

Distributed Systems COMP 212. Lecture 8 Othon Michail

Distributed Systems COMP 212. Lecture 8 Othon Michail Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource

More information

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/

More information

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Avro

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Avro About the Tutorial Apache Avro is a language-neutral data serialization system, developed by Doug Cutting, the father of Hadoop. This is a brief tutorial that provides an overview of how to set up Avro

More information

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple

More information

TWO-DIMENSIONAL FIGURES

TWO-DIMENSIONAL FIGURES TWO-DIMENSIONAL FIGURES Two-dimensional (D) figures can be rendered by a graphics context. Here are the Graphics methods for drawing draw common figures: java.awt.graphics Methods to Draw Lines, Rectangles

More information

Inheritance (cont) Abstract Classes

Inheritance (cont) Abstract Classes Inheritance (cont) Abstract Classes 1 Polymorphism inheritance allows you to define a base class that has fields and methods classes derived from the base class can use the public and protected base class

More information

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by

More information

MTAT Systems Modelling Statechart modeling, simulation and execution using Yakindu

MTAT Systems Modelling Statechart modeling, simulation and execution using Yakindu MTAT.03.083 Systems Modelling Statechart modeling, simulation and execution using Yakindu Abel Armas-Cervantes, Marlon Dumas and Luciano García-Bañuelos In this practice session, you will learn how to

More information

CISC 3115 TY3. C09a: Inheritance. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 9/20/2018 CUNY Brooklyn College

CISC 3115 TY3. C09a: Inheritance. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 9/20/2018 CUNY Brooklyn College CISC 3115 TY3 C09a: Inheritance Hui Chen Department of Computer & Information Science CUNY Brooklyn College 9/20/2018 CUNY Brooklyn College 1 Outline Inheritance Superclass/supertype, subclass/subtype

More information

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide

CS1092: Tutorial Sheet: No 3 Exceptions and Files. Tutor s Guide CS1092: Tutorial Sheet: No 3 Exceptions and Files Tutor s Guide Preliminary This tutorial sheet requires that you ve read Chapter 15 on Exceptions (CS1081 lectured material), and followed the recent CS1092

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

Principles, Models, and Applications for Distributed Systems M

Principles, Models, and Applications for Distributed Systems M Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Exercitation 3 Connected Java Sockets Jacopo De Benedetto Distributed architecture

More information

File Input and Output Review CSC 123 Fall 2018 Howard Rosenthal

File Input and Output Review CSC 123 Fall 2018 Howard Rosenthal File Input and Output Review CSC 123 Fall 218 Howard Rosenthal Lesson Goals The File Class creating a File object Review FileWriter for appending to files Creating a Scanner object to read from a File

More information

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003 The University of Melbourne Department of Computer Science and Software Engineering 433-254 Software Design Semester 2, 2003 Answers for Tutorial 7 Week 8 1. What are exceptions and how are they handled

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

Final Exam. CSC 121 Fall Lecturer: Howard Rosenthal. Dec. 13, 2017

Final Exam. CSC 121 Fall Lecturer: Howard Rosenthal. Dec. 13, 2017 Your Name: Final Exam. CSC 121 Fall 2017 Lecturer: Howard Rosenthal Dec. 13, 2017 The following questions (or parts of questions) in numbers 1-17 are all worth 2 points each. The programs have indicated

More information

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)

More information

Restoring data from a backup

Restoring data from a backup Restoring data from a backup The following topics explain how to find a backup to restore and then perform a restore: Finding a backup to restore on page 98 Restoring to the original location on page 101

More information

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling

Overview. Building Graphical User Interfaces. GUI Principles. AWT and Swing. Constructing GUIs Interface components GUI layout Event handling Overview Building Graphical User Interfaces Constructing GUIs Interface components GUI layout Event handling 4.1 GUI Principles AWT and Swing Components: GUI building blocks. Buttons, menus, sliders, etc.

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Singleton. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 29

Singleton. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 29 Singleton Computer Science and Engineering College of Engineering The Ohio State University Lecture 29 Preventing Instantiation Default (zero-argument) constructor Provided only if there is no explicit

More information

getting STARTed Virtual Coin Cabinet 2v9 beta COIN database SOFTWARe STePHeN HUSTON FileMaker Pro developer .A FIleMAKeR PRO 10 RUNTIMe SOlUTION

getting STARTed Virtual Coin Cabinet 2v9 beta COIN database SOFTWARe STePHeN HUSTON FileMaker Pro developer .A FIleMAKeR PRO 10 RUNTIMe SOlUTION getting STARTed Virtual Coin Cabinet 2v9 beta COIN database SOFTWARe.A FIleMAKeR PRO 10 RUNTIMe SOlUTION JanuarY 2010 STePHeN HUSTON FileMaker Pro developer data ex Machina www.dataxm.com getting started

More information

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment PA4: Multi-thread File Downloader Page 1 Assignment What to Submit Write a program that downloads a file from the Internet using multiple threads. The application has a Graphical Interface written in JavaFX,

More information

Special error return Constructors do not have a return value What if method uses the full range of the return type?

Special error return Constructors do not have a return value What if method uses the full range of the return type? 23 Error Handling Exit program (System.exit()) usually a bad idea Output an error message does not help to recover from the error Special error return Constructors do not have a return value What if method

More information