The javabook Package

Size: px
Start display at page:

Download "The javabook Package"

Transcription

1 A The javabook Package We document the javabook classes in this appendix. You can get information on the standard Java packages from a number of sources. If you use commercial Java compilers from Borland, Microsoft, Symantec, and others, you can access desired information from their help menu. You can also access the online documentation from the Web site at packages.html. Reference books on the standard Java packages such as P. Chan and R. Lee, The Java Class Libraries, Vol. 1 and 2, 2nd ed. [Reading, MA: Addison-Wesley, 1998] and D. Flanagan, Java in a Nutshell, 2nd ed. [Sebastapol, CA: O Reilly & Associates, Inc., 1997] are good sources of information. If you are interested in the official language specification of Java, you should get a copy of J. Gosling, B. Joy, and G. Steele, The Java Language Specification, [Reading, MA: Addison-Wesley, 1996]. Documentation provided in this appendix is intended for the users of the package. As such, only the public methods and constants are included (in case of JavaBookDialog, the protected method is included also). We direct those who are interested in learning how the classes are implemented to our Web site at The Web site includes the most up-to-date online documentation on the javabook package that you can download. We plan to update the javabook package periodically, so please visit our Web site regularly. Also, if you notice any discrepancy between the information provided in this 823

2 824 Appendix A The javabook Package appendix and the software, please visit our Web site to get the most up-to-date information. PACKAGE: Class Convert DrawingBoard Format InputBox JavaBookDialog ListBox MainWindow MessageBox MultiInputBox OutputBox ResponseBox SketchPad javabook Description The class provides methods for converting a value of one data type to another data type. A frame window that is capable of drawing lines, circles, and rectangles. The class provides methods for formatting integers, real numbers, and strings. A dialog for getting an input value from the user. An InputBox object can be used to accept integers, real numbers, and strings. An abstract superclass that encapsulates behavior common to all dialogs in this package: InputBox, ListBox, MessageBox, MultiInput- Box, OutputBox, and ResponseBox. A dialog for displaying a list of choices and allowing the user to select a choice in the list. A frame window that serves as the main window of an application. A MainWindow object is almost as big as the screen and is displayed at the center of the screen. A dialog for displaying a single line of text. A MessageBox object is intended for displaying a short warning or error message. A dialog for getting multiple input values from the user. A MultiInputBox object can be used to accept N string values. A dialog for displaying multiple lines of text. A dialog for getting a yes or no answer from the user. A frame window that allows the user to draw freeform lines using a mouse. For each class description, we include The purpose of the class. The page and section number where the class is introduced. The ancestors of the class. If the superclass is also in the javabook package, then only this superclass is shown. The public constants of the class. The public methods of the class.

3 825 javabook.convert This class provides methods for converting a data value of one data type to another data type. This class is noninstantiable; all methods are class methods. Introduced in: Section 9.4 page 454. java.lang.object Convert toboolean tochar todouble tofloat toint tolong tostring public static boolean toboolean ( String str ) Converts the argument str to a boolean. public static char tochar ( String str ) Converts the argument str to a char. public static double todouble ( String str ) Converts the argument str to a double. public static float tofloat ( String str ) Converts the argument str to a float. public static int toint ( String str ) Converts the argument str to an int.

4 826 Appendix A The javabook Package public static long tolong ( String str ) Converts the argument str to a long. public static String tostring ( boolean bool ) public static String tostring ( char ch ) public static String tostring ( double number ) public static String tostring ( float number ) public static String tostring ( int number ) public static String tostring ( long number ) Converts the argument to a String. javabook.drawingboard This class is used in the sample program from Chapter 6. A DrawingBoard object supports methods for drawing circles, lines, and rectangles. Introduced in: Section 6.6 page 267. MainWindow DrawingBoard DrawingBoard drawcircle drawline drawrectangle setcolor show public DrawingBoard ( ) public DrawingBoard ( String title )

5 827 A DrawingBoard object with the default title DRAWING BOARD is created. The window is not resizable and the background color is set to white. public void drawcircle ( int x, int y, int r ) Draws a circle with radius r and whose center point is (x, y). public void drawline ( int x1, int y1, int x2, int y2 ) Draws a line from point (x1, y1) to (x2, y2). public void drawrectangle ( int x, int y, int w, int h ) public void drawrectangle ( Rectangle rect ) The first version draws a rectangle with width w and height h and its top-left corner at position (x, y). The second version draws a rectangle with the dimension set by the Rectangle object rect. public void show ( ) Overrides the superclass s show to initialize the data member Graphics object so the drawing works correctly. See also: java.awt.rectangle Explanation of the coordinate system for the drawing is given in Section 2.6 and Section javabook.format This class provides methods for formatting a value in a field of a given length. Three possible alignments are left, center, and right. The alignment is done by converting a value to a String with a given length and placing the value at the beginning, middle, or the end of the String. This class is noninstantiable; all methods are class methods. Introduced in: Section 7.7 page 325.

6 828 Appendix A The javabook Package java.lang.object Format centeralign leftalign rightalign public String centeralign ( int width, int decimalplaces, double num ) public String centeralign ( int width, long num ) public String centeralign ( int width, String str ) Returns a String that has width characters in it. The value num or str is positioned at the center of the resulting String. For the first version, the resulting String will have a decimal point and the designated number of decimal places. If the given value cannot fit into the width characters, the value converted to a String without any alignment is returned. public String leftalign ( int width, int decimalplaces, double num ) public String leftalign ( int width, long num ) public String leftalign ( int width, String str ) The same functionality as centeralign, but with the left alignment. public String rightalign ( int width, int decimalplaces, double num ) public String rightalign ( int width, long num ) public String rightalign ( int width, String str ) The same functionality as centeralign, but with the right alignment.

7 829 javabook.inputbox A dialog that allows the user to enter a value. An InputBox object can accept both numerical and textual values. The user cannot close the dialog until he/ she enters a valid value of the designated data type. Introduced in: Section 3.5 page 103. JavaBookDialog InputBox InputBox getinteger getfloat getstring public InputBox ( Frame owner ) public InputBox ( Frame owner, String title) Creates an InputBox object with owner as its controlling Frame object. In the second version, the title of a dialog is set to the String passed as the second argument. public int getinteger ( ) public int getinteger ( String prompt ) The method returns the integer value entered by the user. This method does not complete until the user enters a valid integer. For the first version, the prompt is set to a default word Enter an integer:. In the second version, the prompt is set to the passed String argument. public float getfloat ( ) public float getfloat ( String prompt ) The same behavior as the getinteger methods. The getfloat methods return a float instead of an int.

8 830 Appendix A The javabook Package public String getstring ( ) public String getstring ( String prompt ) The same behavior as the getinteger methods. The getstring methods return a String instead of an int. javabook.javabookdialog An abstract class that encapsulates behavior common to the other dialogs in this package. Create a subclass of JavaBookDialog if you want your dialog to include the common behavior of placing the dialog at the center of the screen. A subclass of JavaBookDialog must implement the abstract method adjustsize. Introduced in: Section page 765 java.lang.object java.awt.component java.awt.container java.awt.window java.awt.dialog JavaBookDialog show public void show ( ) Overrides the superclass s show. This method calls the protected adjustsize method before making the dialog visible. If you create a subclass of JavaBookDialog, then you must define the adjustsize method in your subclass.

9 831 Protected Methods: adjustsize abstract protected void adjustsize ( ) Define this method in your subclass. You use this method to adjust the size of a dialog based on the components placed on the dialog. See also: For a sample of defining a subclass of JavaBookDialog, please read the StudentNameDialog class in Section javabook.listbox A dialog that allows the user to select an entry from a list of selections. Introduced in: Section 6.4 page 256. JavaBookDialog ListBox CANCEL NO_SELECTION ListBox additem deleteitem getselectedindex getselecteditem iscanceled public ListBox ( Frame owner ) public ListBox ( Frame owner, String title ) public ListBox ( Frame owner, boolean modal ) public ListBox ( Frame owner, String title, boolean modal )

10 832 Appendix A The javabook Package Creates a ListBox object with owner as its controlling Frame object. The default title of the dialog is Select One: and the default mode is modal. Pass a String value and/or a boolean value to change the default. You pass true for modal and false for modeless dialogs. public void deleteitem ( int index ) Deletes the entry at position index. The topmost entry is index 0, the next is index 1, and so forth. public void additem ( String entry ) Adds an entry to the list. The newly added entry is placed at the bottom of the list, that is, the newly added entry has the highest index value. public int getselectedindex ( ) Returns the index of the entry selected by the user. If the user clicks the CANCEL button or closes the dialog, then the public constant CANCEL is returned. If the user clicks the OK button without selecting an entry, then the public constant NO_SELECTION is returned. public String getitemfromindex( int index ) Returns the value (String) of the entry at position index. public boolean iscanceled ( ) Returns true if the dialog was canceled or closed without an entry being selected. Returns false otherwise. javabook.mainwindow A frame that serves as the main window of an application. By default, the frame size is almost as large as the screen, and it is displayed at the center of the screen. Introduced in: Section 2.1 page 42.

11 833 java.lang.object java.awt.component java.awt.container java.awt.window java.awt.frame MainWindow MainWindow show public MainWindow ( ) public MainWindow ( String title ) Creates a MainWindow object with the text Sample Java Appliation as its default title. Use the second constructor to change the default title. public void show ( ) Displays the MainWindow object. javabook.messagebox A dialog that displays a single line of text. This dialog is suitable for displaying error or warning messages. Introduced in: Section 2.5 page 65.

12 834 Appendix A The javabook Package JavaBookDialog MessageBox MessageBox show public MessageBox ( Frame owner ) public MessageBox ( Frame owner, boolean modal ) Creates a MessageBox object with owner as its controlling Frame object. The default mode is modal. The second argument determines the modality: pass true for modal and false for modeless. public void show ( long number ) public void show ( double number ) public void show ( String str ) public void show ( StringBuffer strbuf ) Displays the passed argument. Non-String values are converted to a String value before the display. The dialog appears at the center of the screen. public void show ( long number, int x, int y ) public void show ( double number, int x, int y ) public void show ( String str, int x, int y ) public void show ( StringBuffer strbuf, int x, int y ) Displays the passed argument. Non-String values are converted to a String value before the display. The top left corner of the dialog is set to position (x, y). javabook.multiinputbox A dialog that allows the user to enter N input String values. TextField objects are used for accepting input values. Introduced in: Section 9.4 page 452.

13 835 JavaBookDialog MultiInputBox MultiInputBox getinputs iscanceled setlabels setvalue public MultiInputBox ( Frame owner, int size ) public MultiInputBox ( Frame owner, String[] labels ) Creates a MultiInputBox object with owner as its controlling Frame object. The second argument can be either an integer or an array of String objects. The integer value determines N the number of input values the user can enter. If an array of String values is passed, then the value for N is determined by the length of the array. In addition, the String values will become the labels for the N TextField objects. public String[] getinputs ( ) Returns the N input text values entered by the user. An empty String is returned for a TextField that has no entry. public boolean iscanceled ( ) Returns true if the dialog was canceled or closed. Returns false otherwise. public void setlabels ( String[] labels ) Sets the labels for N TextField objects. public void setvalue ( int index, String value ) The text of the TextField object at position index is set to value. The N TextField objects are indexed by using zero-based indexing, that is, the topmost object has index 0. This method is useful for showing the user a typically expected input value. See also: java.awt.textfield

14 836 Appendix A The javabook Package javabook.outputbox A dialog for displaying multiple lines of text. This dialog is intended for displaying program output. Introduced in: Section 3.6 page 106. JavaBookDialog OutputBox OutputBox appendtofile print printline savetofile setfont skipline waituntilclose public OutputBox ( Frame owner ) public OutputBox ( Frame owner, String title ) public OutputBox ( Frame owner, int width, int height ) public OutputBox ( Frame owner, int width, int height, String title ) Creates an OutputBox object with owner as its controlling Frame object. public void appendtofile ( String filename ) Appends the contents of an OutputBox to the file whose name is filename. If no such file exists, then the method creates a new file and saves the contents of an OutputBox.

15 837 public void print ( boolean bool ) public void print ( char ch ) public void print ( double num ) public void print ( long num ) public void print ( String str ) public void print ( StringBuffer strbuf ) Prints out the argument. public void printline ( boolean bool ) public void printline ( char ch ) public void printline ( double num ) public void printline ( long num ) public void printline ( String str ) public void printline ( StringBuffer strbuf ) Prints out the argument and moves the cursor to the next line. public void savetofile ( String filename ) Saves the contents of an OutputBox to the file whose name is filename. If the file already exists, then the original contents of the file will be replaced by the contents of an OutputBox. public void setfont ( Font newfont ) Sets the font to newfont. The default is size 12, plain Courier font. public void skipline ( int numlines ) Skip numlines lines. The effect is the same as if you press the ENTER key numlines times. public void waituntilclose ( ) An OutputBox dialog is always modeless. There are times, however, you want to close the dialog before continuting the execution of a program, that is, you want it to behave like a modal dialog. When this method is called, the program execution will not continue until the user closes the OutputBox object. See also: java.awt.font

16 838 Appendix A The javabook Package javabook.responsebox A dialog for displaying multiple lines of text. This dialog is intended for displaying program output. Introduced in: Section 7.4 page 312. JavaBookDialog ResponseBox YES NO CANCEL BUTTON1 ( == YES) BUTTON2 ( == NO ) BUTTON3 ResponseBox prompt setlabel public ResponseBox ( Frame owner ) public ResponseBox ( Frame owner, int buttoncount ) Creates a ResponseBox object with owner as its controlling Frame object. The default ResponseBox object has two buttons labeled Yes and No. These buttons are identified by the class constants YES and NO. You can create a ResponseBox object with N, 1 ð N ð 3, buttons by passing N as the second argument. The buttons are identified from left to right by the class constants BUTTON1, BUTTON2, and BUTTON3. public int prompt ( String str) Prompts the user for a response. The argument str is the query you pose to the user. The user responds to the query by clicking one of the buttons. public void setlabel ( int id, String label) Set the label of button id to label.

17 839 javabook.sketchpad A frame window that allows the user to draw freeform lines using a mouse. You draw lines by dragging the mouse and erase them by clicking the right mouse button (Command-click on the Mac). Introduced in: Section 1.6 page 33. MainWindow SketchPad SketchPad public SketchPad ( ) Creates a SketchPad object.

18 840 Appendix A The javabook Package

Solutions to Chapter Exercises. GUI Objects and Event-Driven Programming

Solutions to Chapter Exercises. GUI Objects and Event-Driven Programming Solutions to Chapter Exercises 13 GUI Objects and Event-Driven Programming 13.1. Discuss the major difference between a frame and a dialog. 1. Frame can have a menu while Dialog cannot. 2. Dialog can be

More information

Non-instantiable Classes

Non-instantiable Classes Instantiable Classes It is not acceptable to write a program using just the main method. Why? Programs become too large and unmanageable It is not acceptable to write programs using just predefined classes.

More information

index.pdf January 21,

index.pdf January 21, index.pdf January 21, 2013 1 ITI 1121. Introduction to Computing II Circle Let s complete the implementation of the class Circle. Marcel Turcotte School of Electrical Engineering and Computer Science Version

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance (part II) Polymorphism Version of January 21, 2013 Abstract These lecture notes

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance (part II) Polymorphism Version of January 21, 2013 Abstract These lecture notes

More information

Chapter 7 Applets. Answers

Chapter 7 Applets. Answers Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

2. The object-oriented paradigm

2. The object-oriented paradigm 2. The object-oriented paradigm Plan for this section: Look at things we have to be able to do with a programming language Look at Java and how it is done there Note: I will make a lot of use of the fact

More information

Java. Representing Data. Representing data. Primitive data types

Java. Representing Data. Representing data. Primitive data types Computer Science Representing Data Java 02/23/2010 CPSC 449 161 Unless otherwise noted, all artwork and illustrations by either Rob Kremer or Jörg Denzinger (course instructors) Representing data Manipulating

More information

MiG Calendar JavaBeans API. Ellen Bergdahl

MiG Calendar JavaBeans API. Ellen Bergdahl MiG Calendar JavaBeans API Ellen Bergdahl MiG InfoCom AB 2007 Package com.miginfocom.beans Page 2 of 196 com.miginfocom.beans.abstractheaderbean com.miginfocom.beans Class AbstractHeaderBean java.lang.object

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

Chapter 9. Arrays. Declare and use an array of primitive data types in writing a program. Declare and use an array of objects in writing a program.

Chapter 9. Arrays. Declare and use an array of primitive data types in writing a program. Declare and use an array of objects in writing a program. Chapter 9 Arrays OBJECTIVES After you have read and studied this chapter, you should be able to Manipulate a collection of data values using an array. Declare and use an array of primitive data types in

More information

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM Objectives The objectives of this assignment are: to refresh your Java programming to become familiar with

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Textadept Quick Reference

Textadept Quick Reference THIRD EDITION Textadept Quick Reference Mitchell Textadept Quick Reference by Mitchell Copyright 2013, 2015, 2016 Mitchell. All rights reserved. Contact the author at mitchell@foicica.com. Although great

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

InDesign Part II. Create a Library by selecting File, New, Library. Save the library with a unique file name.

InDesign Part II. Create a Library by selecting File, New, Library. Save the library with a unique file name. InDesign Part II Library A library is a file and holds a collection of commonly used objects. A library is a file (extension.indl) and it is stored on disk. A library file can be open at any time while

More information

Programming: You will have 6 files all need to be located in the dir. named PA4:

Programming: You will have 6 files all need to be located in the dir. named PA4: PROGRAMMING ASSIGNMENT 4: Read Savitch: Chapter 7 and class notes Programming: You will have 6 files all need to be located in the dir. named PA4: PA4.java ShapeP4.java PointP4.java CircleP4.java RectangleP4.java

More information

Textadept Quick Reference. Mitchell

Textadept Quick Reference. Mitchell Textadept Quick Reference Mitchell Textadept Quick Reference by Mitchell Copyright 2013 Mitchell. All rights reserved. Contact the author at mitchell.att.foicica.com. Although great care has been taken

More information

Lesson 7: Graphics (cont) Ricardo Salazar, Pic 10A

Lesson 7: Graphics (cont) Ricardo Salazar, Pic 10A Lesson 7: Graphics (cont) Ricardo Salazar, Pic 10A (2.8) Graphics Window (Input) cwin can output shapes and text. E.g. cwin

More information

Question 2. [5 points] Given the following symbolic constant definition

Question 2. [5 points] Given the following symbolic constant definition CS 101, Spring 2012 Mar 20th Exam 2 Name: Question 1. [5 points] Determine which of the following function calls are valid for a function with the prototype: void drawrect(int width, int height); Assume

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract

More information

CS 1302 Chapter 9 (Review) Object & Classes

CS 1302 Chapter 9 (Review) Object & Classes CS 1302 Chapter 9 (Review) Object & Classes Reference Sections 9.2-9.5, 9.7-9.14 9.2 Defining Classes for Objects 1. A class is a blueprint (or template) for creating objects. A class defines the state

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Inheritance 2. Inheritance 2. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

Inheritance 2. Inheritance 2. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Inheritance 2 Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.jku.at http://www.risc.jku.at Wolfgang Schreiner RISC

More information

Binghamton University. CS-140 Fall Data Types in Java

Binghamton University. CS-140 Fall Data Types in Java Data Types in Java 1 CS-211 2015 Example Class: Car How Cars are Described Make Model Year Color Owner Location Mileage Actions that can be applied to cars Create a new car Transfer ownership Move to a

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

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;

More information

Getting Started with Milestone 2. From Lat Lon, to Cartesian, and back again

Getting Started with Milestone 2. From Lat Lon, to Cartesian, and back again Getting Started with Milestone 2 From Lat Lon, to Cartesian, and back again Initial Steps 1. Download m2 handout 2. Follow the walkthrough in Section 4 3. Read the EZGL QuickStart Guide 4. Modify main.cpp

More information

CPE Summer 2015 Exam I (150 pts) June 18, 2015

CPE Summer 2015 Exam I (150 pts) June 18, 2015 Name Closed notes and book. If you have any questions ask them. Write clearly and make sure the case of a letter is clear (where applicable) since C++ is case sensitive. You can assume that there is one

More information

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed 1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every

More information

12/22/11. Java How to Program, 9/e. public must be stored in a file that has the same name as the class and ends with the.java file-name extension.

12/22/11. Java How to Program, 9/e. public must be stored in a file that has the same name as the class and ends with the.java file-name extension. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Covered in this chapter Classes Objects Methods Parameters double primitive type } Create a new class (GradeBook) } Use it to create an object.

More information

OCTAVO An Object Oriented GUI Framework

OCTAVO An Object Oriented GUI Framework OCTAVO An Object Oriented GUI Framework Federico de Ceballos Universidad de Cantabria federico.ceballos@unican.es November, 2004 Abstract This paper presents a framework for building Window applications

More information

This project is the design and implementation of a mini-language to introduce and

This project is the design and implementation of a mini-language to introduce and ABSTRACT This project is the design and implementation of a mini-language to introduce and simplify the practice of object-oriented programming. The Plain language is a subset of the Java language and

More information

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

User Manual. pdoc Forms Designer. Version 3.7 Last Update: May 25, Copyright 2018 Topaz Systems Inc. All rights reserved.

User Manual. pdoc Forms Designer. Version 3.7 Last Update: May 25, Copyright 2018 Topaz Systems Inc. All rights reserved. User Manual pdoc Forms Designer Version 3.7 Last Update: May 25, 2018 Copyright 2018 Topaz Systems Inc. All rights reserved. For Topaz Systems, Inc. trademarks and patents, visit www.topazsystems.com/legal.

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

Full file at Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries

Full file at   Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries MULTIPLE CHOICE 1. To start a new line in a cell, press after each line, except for the last line, which is completed by clicking the

More information

CS242 COMPUTER PROGRAMMING

CS242 COMPUTER PROGRAMMING CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3

More information

1 Getting started with Processing

1 Getting started with Processing cisc3665, fall 2011, lab I.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

Instructions for Crossword Assignment CS130

Instructions for Crossword Assignment CS130 Instructions for Crossword Assignment CS130 Purposes: Implement a keyboard interface. 1. The program you will build is meant to assist a person in preparing a crossword puzzle for publication. You have

More information

GUI Components: Part 1

GUI Components: Part 1 1 2 11 GUI Components: Part 1 Do you think I can listen all day to such stuff? Lewis Carroll Even a minor event in the life of a child is an event of that child s world and thus a world event. Gaston Bachelard

More information

Developer Manual. Guide to Library Implementation 1 CONTENT TERMINOLOGY LIBRARY IMPLEMENTATION COMPONENT IMPLEMENTATION...

Developer Manual. Guide to Library Implementation 1 CONTENT TERMINOLOGY LIBRARY IMPLEMENTATION COMPONENT IMPLEMENTATION... . Developer Manual Guide to Library Implementation 1 Content 1 CONTENT...1 2 TERMINOLOGY...2 3 LIBRARY IMPLEMENTATION...3 4 COMPONENT IMPLEMENTATION...4 2.1 SETTING GRID SIZE AND GRID LOCATIONS...5 2.2

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

Java Application Development

Java Application Development A Absolute Size and Position - Specifying... 10:18 Abstract Class... 5:15 Accessor Methods...4:3-4:4 Adding Borders Around Components... 10:7 Adding Components to Containers... 10:6 Adding a Non-Editable

More information

Chapter 3 - Introduction to Java Applets

Chapter 3 - Introduction to Java Applets 1 Chapter 3 - Introduction to Java Applets 2 Introduction Applet Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language)

More information

Redlining Commands After retrieving a drawing to be redlined, select Redline from the Slick! menu bar or pick from one of the icons in the tool bar.

Redlining Commands After retrieving a drawing to be redlined, select Redline from the Slick! menu bar or pick from one of the icons in the tool bar. Annotate / Redlining During the design review process in working with engineering or architectural drawings, it is often useful to have the ability to look at a drawing and mark it up with comments or

More information

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at Interfaces.

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at  Interfaces. Today Book-keeping Inheritance Subscribe to sipb-iap-java-students Interfaces Slides and code at http://sipb.mit.edu/iap/java/ The Object class Problem set 1 released 1 2 So far... Inheritance Basic objects,

More information

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1 Merchandise Inheritance Systems Electronics Clothing Television Camcorder Shirt Shoe Dress Digital Analog 9.1.1 Another AcademicDisciplines Hierarchy Mathematics Engineering Algebra Probability Geometry

More information

Supporting both Exploratory Design and Power of Action with a New Property Sheet

Supporting both Exploratory Design and Power of Action with a New Property Sheet Raphaël Hoarau Université de Toulouse ENAC - IRIT/ICS 7, rue Edouard Belin Toulouse, 31055 France raphael.hoarau@enac.fr Stéphane Conversy Université de Toulouse ENAC - IRIT/ICS 7, rue Edouard Belin Toulouse,

More information

Forms iq Designer Training

Forms iq Designer Training Forms iq Designer Training Copyright 2008 Feith Systems and Software, Inc. All Rights Reserved. No part of this publication may be reproduced, transmitted, stored in a retrieval system, or translated into

More information

In this lab, you will be given the implementation of the classes GeometricObject, Circle, and Rectangle, as shown in the following UML class diagram.

In this lab, you will be given the implementation of the classes GeometricObject, Circle, and Rectangle, as shown in the following UML class diagram. Jordan University Faculty of Engineering and Technology Department of Computer Engineering Object-Oriented Problem Solving: CPE 342 Lab-8 Eng. Asma Abdel Karim In this lab, you will be given the implementation

More information

2. The object-oriented paradigm!

2. The object-oriented paradigm! 2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of

More information

Informatics 1 Functional Programming Lecture 9. Algebraic Data Types. Don Sannella University of Edinburgh

Informatics 1 Functional Programming Lecture 9. Algebraic Data Types. Don Sannella University of Edinburgh Informatics 1 Functional Programming Lecture 9 Algebraic Data Types Don Sannella University of Edinburgh Part I Algebraic types Everything is an algebraic type data Bool = False True data Season = Winter

More information

Click File on the menu bar to view the individual menu items and their associated icons on the File menu.

Click File on the menu bar to view the individual menu items and their associated icons on the File menu. User Interface Design 387 STEP 3 Click File on the menu bar to view the individual menu items and their associated icons on the File menu. The standard File menu items (New, Open, Save, Save As, Print,

More information

Custom Types. Outline. COMP105 Lecture 19. Today Creating our own types The type keyword The data keyword Records

Custom Types. Outline. COMP105 Lecture 19. Today Creating our own types The type keyword The data keyword Records Outline COMP105 Lecture 19 Custom Types Today Creating our own types The type keyword The data keyword Records Relevant book chapters Programming In Haskell Chapter 8 Learn You a Haskell Chapter 8 The

More information

Simple Component Writer's Guide

Simple Component Writer's Guide Simple Component Writer's Guide Note that most of the following also applies to writing ordinary libraries for Simple. The preferred language to write Simple components is Java, although it should be possible

More information

JASCO CANVAS PROGRAM OPERATION MANUAL

JASCO CANVAS PROGRAM OPERATION MANUAL JASCO CANVAS PROGRAM OPERATION MANUAL P/N: 0302-1840A April 1999 Contents 1. What is JASCO Canvas?...1 1.1 Features...1 1.2 About this Manual...1 2. Installation...1 3. Operating Procedure - Tutorial...2

More information

Java Classes & Primitive Types

Java Classes & Primitive Types Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)

More information

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof Abstract Class Lecture 21 Based on Slides of Dr. Norazah Yusof 1 Abstract Class Abstract class is a class with one or more abstract methods. The abstract method Method signature without implementation

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

XnView Image Viewer. a ZOOMERS guide

XnView Image Viewer. a ZOOMERS guide XnView Image Viewer a ZOOMERS guide Introduction...2 Browser Mode... 5 Image View Mode...14 Printing... 22 Image Editing...26 Configuration... 34 Note that this guide is for XnView version 1.8. The current

More information

CS 11 java track: lecture 3

CS 11 java track: lecture 3 CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces

More information

Java Classes & Primitive Types

Java Classes & Primitive Types Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)

More information

TYPE EDIT V12. Tutorial 03. Multicopy to create a set of medals COPYRIGHT 2014 GRAVOTECH MARKING SAS ALL RIGHTS RESERVED

TYPE EDIT V12. Tutorial 03. Multicopy to create a set of medals COPYRIGHT 2014 GRAVOTECH MARKING SAS ALL RIGHTS RESERVED TYPE EDIT V12 Multicopy to create a set of medals COPYRIGHT 2014 GRAVOTECH MARKING SAS ALL RIGHTS RESERVED Multicopy to create a set of medals Creation Time : 45 minutes Level : Intermediate Module : TypeEdit

More information

F I N A L E X A M I N A T I O N

F I N A L E X A M I N A T I O N Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student

More information

SIMPLE TEXT LAYOUT FOR COREL DRAW. When you start Corel Draw, you will see the following welcome screen.

SIMPLE TEXT LAYOUT FOR COREL DRAW. When you start Corel Draw, you will see the following welcome screen. SIMPLE TEXT LAYOUT FOR COREL DRAW When you start Corel Draw, you will see the following welcome screen. A. Start a new job by left clicking New Graphic. B. Place your mouse cursor over the page width box.

More information

Chapter 4. Defining Instantiable Classes

Chapter 4. Defining Instantiable Classes Chapter 4 Defining Instantiable Classes OBJECTIVES After you have read and studied this chapter, you should be able to Define an instantiable class with multiple methods and a constructor. Differentiate

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

Midterm Exam 5 April 20, 2015

Midterm Exam 5 April 20, 2015 Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.

More information

The AWT Package, An Overview

The AWT Package, An Overview Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, An Overview Java Programming, Lecture Notes # 110, Revised 02/21/98. Preface Introduction

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba Laboratory Session: Exercises on classes Analogy to help you understand classes and their contents. Suppose you want to drive a car and make it go faster by pressing down

More information

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism Ibrahim Albluwi Composition A GuitarString has a RingBuffer. A MarkovModel has a Symbol Table. A Symbol Table has a Binary

More information

Lab 9: Creating a Reusable Class

Lab 9: Creating a Reusable Class Lab 9: Creating a Reusable Class Objective This will introduce the student to creating custom, reusable classes This will introduce the student to using the custom, reusable class This will reinforce programming

More information

(SSOL) Simple Shape Oriented Language

(SSOL) Simple Shape Oriented Language (SSOL) Simple Shape Oriented Language Madeleine Tipp Jeevan Farias Daniel Mesko mrt2148 jtf2126 dpm2153 Description: SSOL is a programming language that simplifies the process of drawing shapes to SVG

More information

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Inheritance, Polymorphism, and Interfaces

Inheritance, Polymorphism, and Interfaces Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)

More information

IST311. Advanced Issues in OOP: Inheritance and Polymorphism

IST311. Advanced Issues in OOP: Inheritance and Polymorphism IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition

More information

3 Getting Started with Objects

3 Getting Started with Objects 3 Getting Started with Objects If you are an experienced IDE user, you may be able to do this tutorial without having done the previous tutorial, Getting Started. However, at some point you should read

More information

text++ Joi Anderson - jna2123 // Manager + Tester Klarizsa Padilla - ksp2127 // Language Guru Maria Javier - mj2729 // System Architect + Tester

text++ Joi Anderson - jna2123 // Manager + Tester Klarizsa Padilla - ksp2127 // Language Guru Maria Javier - mj2729 // System Architect + Tester text Programmable, Typesetting PDF Generation for the C Programmer. Joi Anderson - jna2123 // Manager + Tester Klarizsa Padilla - ksp2127 // Language Guru Maria Javier - mj2729 // System Architect + Tester

More information

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help CS 2110 Fall 2012 Homework 4 Paint Program Due: Wednesday, 12 November, 11:59PM In this assignment, you will write parts of a simple paint program. Some of the functionality you will implement is: 1. Freehand

More information

Inheritance. Inheritance

Inheritance. Inheritance 1 2 1 is a mechanism for enhancing existing classes. It allows to extend the description of an existing class by adding new attributes and new methods. For example: class ColoredRectangle extends Rectangle

More information

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

Islamic University of Gaza Faculty of Engineering Computer Engineering Department Student Mark Islamic University of Gaza Faculty of Engineering Computer Engineering Department Question # 1 / 18 Question # / 1 Total ( 0 ) Student Information ID Name Answer keys Sector A B C D E A B

More information

AWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.

AWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user. http://www.tutorialspoint.com/awt/awt_dialog.htm AWT DIALOG CLASS Copyright tutorialspoint.com Introduction Dialog control represents a top-level window with a title and a border used to take some form

More information

We are on the GUI fast track path

We are on the GUI fast track path We are on the GUI fast track path Chapter 13: Exception Handling Skip for now Chapter 14: Abstract Classes and Interfaces Sections 1 9: ActionListener interface Chapter 15: Graphics Skip for now Chapter

More information

Notes from the Boards Set # 5 Page

Notes from the Boards Set # 5 Page 1 Yes, this stuff is on the exam. Know it well. Read this before class and bring your questions to class. Starting today, we can no longer write our code as a list of function calls and variable declarations

More information

All classes in a package can be imported by using only one import statement. If the postcondition of a method is not met, blame its implementer

All classes in a package can be imported by using only one import statement. If the postcondition of a method is not met, blame its implementer Java By Abstraction ANSWERS O ES-A GROUP - A For each question, give +0.5 if correct, -0.5 if wrong, and 0 if blank. If the overall total is negative, record it (on the test's cover sheet)

More information

24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini 24. Inheritance Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Superclasses and Subclasses Inheritance

More information

Exam Duration: 2hrs and 30min Software Design

Exam Duration: 2hrs and 30min Software Design Exam Duration: 2hrs and 30min. 433-254 Software Design Section A Multiple Choice (This sample paper has less questions than the exam paper The exam paper will have 25 Multiple Choice questions.) 1. Which

More information

WARM UP LESSONS BARE BASICS

WARM UP LESSONS BARE BASICS WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions

More information