Archive for May, 2007

Free web hosting services - 96 Introduction to Java Applications Chapter 2 command

Tuesday, May 8th, 2007

96 Introduction to Java Applications Chapter 2 command tool mainmethod command window memory comma-separated list memory location comment (//) message compilation error message dialog compile error method compiler Microsoft Internet Explorer browser compile-time error modulus operator (%) condition mouse cursor decision mouse pointer declaration MS-DOS Prompt dialog multiple-line comment dialog box multiplication operator (*) division operator (/) nested parentheses document a program Netscape Navigator browser empty string (”") newline character (n) equality operatorsobject == is equal to operand != is not equal to operator escape sequence package exit method of System parentheses () false parseInt method of class Integer graphical user interface (GUI) precedence identifier primitive data type if structure programmer-defined class import statement prompt input dialog public keyword intprimitive type relational operatorsinteger (int) < is less than Integer class <= is less than or equal to integer division > is greater thaninterpreter >= is greater than or equal to Java reserved words Java 2 Software Development Kit (J2SDK) right brace, }, ends the body of a class Java applications programming interface (API) right brace, }, ends the body of a method Java class library right-to-left associativity Java documentation comment rules of operator precedence .java file extension semicolon (;) statement terminator java interpreter shell tool java.lang package showInputDialog method of JOptionPane javax.swing package showMessageDialogmethod ofJOptionPane class JOptionPane JOptionPane.ERROR_MESSAGE single-line comment JOptionPane.INFORMATION_MESSAGE standard output object JOptionPane.PLAIN_MESSAGE statement JOptionPane.QUESTION_MESSAGE statement terminator (;) JOptionPane.WARNING_MESSAGE staticmethod left brace, {, begins the body of a class straight-line form left brace, {, begins the body of a method string literal String class Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services

Photoshop web design - Chapter 2 Introduction to Java Applications 95

Tuesday, May 8th, 2007

Chapter 2 Introduction to Java Applications 95 A variable is a location in the computer s memory where a value can be stored for use by a program. The name of a variable is any valid identifier. All variables must be declared with a name and a data type before they can be used in a program. Declarations end with a semicolon (;) and can be split over several lines, with each variable in the declaration separated by a comma (forming a comma-separated list of variable names). Variables of type inthold integer values (whole numbers such as 7, 11, 0 and 31,914). Types such as int, float, doubleand char are primitive data types. Names of primitive data types are keywords of the Java programming language. A prompt directs the user to take a specific action. A variable is assigned a value by using an assignment statement, which uses the assignment operator, =. The =operator is called a binary operator, because it has two operands. Method Integer.parseInt(a static method of class Integer) converts its String argument to an intvalue. Java has a version of the + operator for string concatenation that enables a string and a value of another data type (including another string) to be concatenated. Every variable has a name, a type, a size and a value. When a value is placed in a memory location, the value replaces the value previously in that location. When a value is read out of a memory location, the variable s value remains unchanged. The arithmetic operators are binary operators, because they operate on two operands. Integer division yields an integer result. Arithmetic expressions in Java must be written in straight-line form to facilitate entering programs into the computer. Operators in arithmetic expressions are applied in a precise sequence determined by the rules of operator precedence. Parentheses may be used to force the order of evaluation of operators. When we say that operators are applied from left to right, we are referring to the associativity of the operators. Some operators associate from right to left. Java s ifstructure allows a program to make a decision based on the truth or falsity of a condition. If the condition is met (i.e., the condition is true), the statement in the body of the if structure executes. If the condition is not met (i.e., the condition is false), the body statement does not execute. Conditions in if structures can be formed by using the equality operators and relational operators. The empty string is a string containing no characters. Every variable declared in a method must be initialized before it can be used in an expression. TERMINOLOGY addition operator (+) body of a class definition applet body of a method definition application braces ({ and }) argument to a method case sensitive arithmetic operators character string assignment operator (=) class assignment statement class definition associativity of operators .class file extension backslash () escape character class keyword binary operator class name Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

94 Introduction to Java Applications Chapter 2 (Remote web server)

Monday, May 7th, 2007

94 Introduction to Java Applications Chapter 2 Keyword class introduces a class definition and is immediately followed by the class name. Keywords (or reserved words) are reserved for use by Java. Keywords must appear in all lowercase letters. By convention, all class names in Java begin with a capital letter. If a class name contains more than one word, the first letter of each word should be capitalized. An identifier is a series of characters consisting of letters, digits, underscores ( _) and dollar signs ($) that does not begin with a digit, does not contain any spaces and is not a keyword. Java is case sensitive that is, uppercase and lowercase letters are different. A left brace, {, begins the body of every class definition. A corresponding right brace, }, ends each class definition. Java applications begin executing at method main. Methods are able to perform tasks and return information when they complete their tasks. The first line of method main must be defined as public static void main( String args[] ) A left brace, {, begins the body of a method definition. A corresponding right brace, }, ends the method definition s body. System.out is known as the standard output object. System.out allows Java applications to display strings and other types of information in the command window from which the Java application executes. The escape sequence n indicates a newline character. Other escape sequences include t (tab), r (carriage return), \ (backslash) and ” (double quote). Method println of the System.out object displays (or prints) a line of information in the command window. When println completes its task, it automatically positions the output cursor to the beginning of the next line in the command window. Every statement must end with a semicolon (also known as the statement terminator). The difference between System.out s print and println methods is that print does not position to the beginning of the next line in the command window when it finishes displaying its argument. The next character displayed in the command window appears immediately after the last character displayed with print. Java contains many predefined classes that are grouped into categories of related classes called packages. The packages are referred to collectively as the Java class library or the Java applications programming interface (Java API). Class JOptionPane is defined in package javax.swing. Class JOptionPane contains methods that display dialog boxes. The compiler uses import statements to locate classes required to compile a Java program. The javax.swing package contains many classes that help define a graphical user interface (GUI) for an application. GUI components facilitate data entry by the user of a program and data outputs by a program. Method showMessageDialog of class JOptionPane displays a dialog box containing a message to the user. A staticmethod is called by following its class name by a dot (.) and the name of the method. Method exit of class System terminates an application. Class System is in package java.lang. All Java programs import package java.lang by default. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision mysql hosting services

Chapter 2 Introduction to Java Applications 93 www.embarcadero.com (Web hosting top)

Monday, May 7th, 2007

Chapter 2 Introduction to Java Applications 93 www.embarcadero.com This site provides a free 30-day license to download a trial-version of Describe the new UML modeling tool from Embarcadero Technologies . www.ics.uci.edu/pub/arch/uml/uml_books_and_tools.html This site lists books on the UML and software tools that use the UML, such as Rational Rose and Embarcadero Describe . www.ootips.org/ood-principles.html This site provides answers to the question what makes good OOD? wdvl.internet.com/Authoring/Scripting/Tutorial/oo_design.html This site introduces OOD and provides OOD resources. Bibliography Booch, G., Object-Oriented Analysis and Design with Applications. Addison-Wesley. Massachusetts; 1994. Folwer, M., and Scott, K., UML Distilled Second Edition; A Brief Guide to the Standard Object Modeling Language. Addison-Wesley. Massachusetts; 1999. Larman, C., Applying UML and Patterns; An Introduction to Object-Oriented Analysis and Design. Prentice Hall. New Jersey; 1998. Page-Jones, M., Fundamentals of Object-Oriented Design in UML. Addison-Wesley. Massachusetts; 1999. Rumbaugh, J.; Jacobson, I.; and Booch, G., The Unified Modeling Language Reference Manual. Addison-Wesley. Massachusetts; 1999. Rumbaugh, J.; Jacobson, I.; and Booch, G., The Unified Modeling Language User Guide. Addison- Wesley. Massachusetts; 1999. Rumbaugh, J.; Jacobson, I.; and Booch, G., The Complete UML Training Course. Prentice Hall. New Jersey; 2000. Rumbaugh, J.; Jacobson, I.; and Booch, G., The Unified Software Development Process. Addison- Wesley. Massachusetts; 1999. Rosenburg, D., and Scott, K., Applying Use Case Driven Object Modeling with UML: An Annotated e-Commerce Example. Addison-Wesley. Massachusetts; 2001. Schach, S., Object-Oriented and Classical Software Engineering. McGraw Hill. New York; 2001. Schneider, G., and Winters, J., Applying Use Cases. Addison-Wesley. Massachusetts; 1998. Scott, K., UML Explained. Addison-Wesley. Massachusetts; 2001. Stevens, P., and Pooley, R.J., Using UML: Software Engineering with Objects and Components Revised Edition. Addison-Wesley; 2000. SUMMARY An application is a program that executes using the java interpreter. A comment that begins with // is called a single-line comment. Programmers insert comments to document programs and improve program readability. A string of characters contained between double quotation marks is called a string, a character string, a message or a string literal. Blank lines, space characters, newline characters and tab characters are known as white-space characters. White-space characters outside strings are ignored by the compiler. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap webhost to host and run your apache application check Vision jboss web hosting services

Web hosting reviews - 92 Introduction to Java Applications Chapter 2 object

Monday, May 7th, 2007

92 Introduction to Java Applications Chapter 2 object is an instance of class Elevator), and there may be several objects created from one class (e.g., both the first floor button object and the second floor button object are created from class FloorButton). Component diagrams, presented in Section 13.17, model the components resources (which include graphics and audio) and packages (which are groups of classes) that make up the system. Deployment diagrams model the runtime requirements of the system (such as the computer or computers on which the system will reside), memory requirements for the system, or other devices the system requires during execution. We do not present deployment diagrams in this case study, because we are not designing a hardware-specific system our simulation requires only one computer containing the Java 2 runtime environment on which to run. Statechart diagrams, which we introduce in Section 5.11, model how an object changes state (i.e., the condition of an object at a specific time). When an object changes state, that object may behave differently in the system. Activity diagrams, which we also introduce in Section 5.11, model an object s activity that object s workflow during program execution. An activity diagram is a flowchart that models the actions the object will perform and in what order. Both collaboration diagrams and sequence diagrams model the interactions among the objects in a system. Collaboration diagrams emphasize what interactions occur, whereas sequence diagrams emphasize when interactions occur. We introduce these diagrams in Section 7.10 and Section 15.12, respectively. Use-Case diagrams represent the interaction between the user and our system (i.e., all actions the user may perform on the system). We introduce use-case diagrams in Section 12.16, where we discuss user-interface issues. In Thinking About Objects Section 3.17, we continue designing our elevator system by identifying the classes in the problem statement. We accomplish this by extracting all the nouns and noun clauses from the problem statement. Using these classes, we develop a class diagram that models the structure of our elevator simulation system. Internet and World-Wide-Web Resources Listed below are URLs and books on object-oriented design with the UML you may find these references helpful as you study the remaining sections of our case-study presentation. www.omg.com/technology/uml/index.htm This is the UML resourse page from the Object Management Group, which provides specifications for various object-oriented technologies, such as the UML. www.smartdraw.com/drawing/software/indexUML.asp This site shows how to draw UML diagrams without the use of modeling tools. www.rational.com/uml/index.jsp This is the UML resource page for Rational Software Corporation the company that created the UML. microgold.com/Stage/UML_FAQ.html This site provides the UML FAQ maintained by Rational Software. www.softdocwiz.com/Dictionary.htm This site hosts the Unified Modeling Language Dictionary, which lists and defines all terms used in the UML. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision ecommerce web hosting services

Chapter 2 Introduction to Java Applications 91 We (Web hosting providers)

Monday, May 7th, 2007

Chapter 2 Introduction to Java Applications 91 We now begin the design phase of our elevator system, which will span Chapters 2 through 13, Chapter 15 and Chapter 22, in which we gradually develop the design. Appendices G, H and I present the complete Java implementation. A system is a set of components that interact to solve a problem. In our case study, the elevator-simulator application represents the system. A system may contain subsystems, which are systems within a system. Subsystems simplify the design process by managing subsets of system responsibilities. System designers may allocate system responsibilities among the subsystems, design the subsystems, then integrate the subsystems with the overall system. Our elevator-simulation system contains three subsystems, which are defined in the problem statement: 1. the simulator model (which represents the operation of the elevator system), 2. the display of this model on screen (so that the user may view it graphically), and 3. the graphical user interface (that allows the user to control the simulation). We develop the simulator model gradually through Chapter 15 and present the implemented model in Appendix H. We discuss the GUI components allowing the user to control the model in Chapter 12 and introduce how the subsystems work together to form the system in Chapter 13. Finally, we introduce how to display the simulator model on the screen in Chapter 22 and conclude the display in Appendix I. System structure describes the system s objects and their inter-relationships. System behavior describes how the system changes as its objects interact with each other. Every system has both structure and behavior we must design both. However, there are several distinct types of system structures and behaviors. For example, the interaction among the objects in the system differs from the interaction between the user and the system, yet both are interactions that constitute the system behavior. The UML specifies nine types of diagrams for modeling systems. Each diagram models a distinct characteristic of a system s structure or behavior the first four diagrams relate to system structure; the remaining five diagrams relate to system behavior: 1. Class diagram 2. Object diagram 3. Component diagram 4. Deployment diagram 5. Activity diagram 6. Statechart diagram 7. Collaboration diagram 8. Sequence diagram 9. Use-Case diagram Class diagrams, which we explain in Thinking About Objects Section 3.8, model the classes, or building blocks, used to build a system. Each entity in the problem statement is a candidate to be a class in the system (i.e., Person, Elevator, Floor, etc.). Object diagrams, which we also explain in Section 3.8, model a snapshot of the system by modeling a system s objects and their relationships at a specific point in time. Each object represents an instance of a class from the class diagram (e.g., the elevator Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

90 Introduction to Java Applications Chapter 2 The (Sex offenders web site)

Sunday, May 6th, 2007

90 Introduction to Java Applications Chapter 2 The company requests that we display the results of the simulation graphically, as shown in Fig. 2.22, Fig. 2.23 and Fig. 2.24. At various points in time, the screen should display a person walking to the elevator, pressing a button and entering, riding and exiting the elevator. The display also should also show the elevator moving, the doors opening, the lights turning on and off, the buttons illuminating when they are pressed and the buttons darkening when they are reset. The company requests that audio be integrated into the simulation. For example, as a person walks, the application user should hear the footsteps. Each time a floor or elevator button is pressed or reset, the user should hear a click. The bell should ring upon the elevator s arrival, and doors should creak when they open or close. Lastly, elevator music should play as the elevator travels between floors. Analyzing and Designing the Elevator System We must analyze and design our system before we implement it as Java code. The output of the analysis phase is intended to specify clearly in a requirements document what the system is supposed to do. The requirements document for this case study is essentially the description of what the elevator simulator is supposed to do presented informally in the last few pages. The output of the design phase should specify clearly how the system should be constructed to do what is needed. In the next several Thinking About Objects sections, we perform the steps of an object-oriented design (OOD) process on the elevator system. The UML is designed for use with any OOD process many such processes exist. One popular method is the Rational Unified Process developed by Rational Software Corporation. For this case study, we present our own simplified design process. For many of our readers, this will be their first OOD/UML experience. Person exiting and walking Floor light lit when Elevator door open away on floor elevator arrives Fig. 2.24 Person walking away from elevator. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Chapter 2 Introduction to Java Applications 89 First (Web server extensions)

Sunday, May 6th, 2007

Chapter 2 Introduction to Java Applications 89 First floor Second floor Lights Person walking to elevator Elevator Elevator shaft Elevator door Floor buttons GUI button Elevator button Bell (Disabled) GUI button Fig. 2.222 Person moving towards elevator on the first floor. Fig. Fig. 2.2323 Person riding the elevator to the second floor. Fig. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision ecommerce web hosting services

88 Introduction to Java Applications Chapter 2 resent (Web host server)

Sunday, May 6th, 2007

88 Introduction to Java Applications Chapter 2 resent the elevator door because mesh allows us to see inside the elevator). The floor door opens concurrently with the elevator door, so it appears as if both doors open at the same time. A person sees only one door, depending on that person s location. When the person is inside the elevator, the person sees the elevator door and can exit the elevator when this door opens; when the person is outside the elevator, the person sees the floor door and can enter the elevator when that door opens1. The elevator starts on the first floor with all the doors closed. To conserve energy, the elevator moves only when necessary. For simplicity, the elevator and floors each have a capacity of only one person.2 The user of our application should, at any time, be able to create a unique person in the simulation and situate that person on either the first or second floor (Fig. 2.22). When created, the person walks across the floor to the elevator. The person then presses a button on the floor next to the elevator shaft (referred to as a floor button ). When pressed, that floor button illuminates, then requests the elevator. When summoned, the elevator travels to the person s floor. If the elevator is already on that person floor, the elevator does not travel. Upon arrival, the elevator resets the button inside the elevator (called the elevator button ), sounds the bell inside the elevator, then opens the elevator door (which opens the floor door on that floor). The elevator then signals the elevator shaft of the arrival. The elevator shaft, upon receiving this message, resets the floor button and illuminates the light on that floor. Occasionally, a person requests the elevator when it is moving. If the request was generated at the floor from which the elevator just departed, the elevator must remember to revisit that floor after carrying the current passenger to the other floor. When the floor door opens, the person enters the elevator after the elevator passenger (if there is one) exits. If a person neither enters nor requests the elevator, the elevator closes its door and remains on that floor until the next person presses a floor button to summon the elevator. When a person enters the elevator, that person presses the elevator button, which also illuminates when pressed. The elevator closes its door (which also closes the floor door on that floor) and moves to the opposite floor. The elevator takes five seconds to travel between floors. When the elevator arrives at the destination floor, the elevator door opens (along with the floor door on that floor) and the person exits the elevator. The application user introduces a person onto the first or second floor by pressing the First Floor button or the Second Floor button, respectively. When the user presses the First Floor button, a person should be created (by the elevator simulation) and positioned on the first floor of the building. When the user presses the Second Floor button, a person should be created and positioned on the second floor. Over time, the user can create any number of people in the simulation, but the user cannot create a new person on an occupied floor. For example, Fig. 2.22 shows that the First Floor button is disabled to prevent the user from creating more than one person on the first floor. Figure 2.23 shows that this button is reenabled when the person rides the elevator. 1. Most people do not consider this when riding an elevator they really think of one elevator door, when in reality, there is a door in the elevator and a door on the floor, and these doors open and close in tandem. 2. After you have studied this case study, you may want to modify it to allow more than one person to ride the elevator at once and more than one person to wait on each floor at once. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

Web design tools - Chapter 2 Introduction to Java Applications 87 We

Sunday, May 6th, 2007

Chapter 2 Introduction to Java Applications 87 We have introduced many important features of Java in this chapter, including displaying data on the screen, inputting data from the keyboard, performing calculations and making decisions. We should note that these applications are meant to introduce the reader to basic programming concepts. As you will see in later chapters, more substantial Java applications contain just a few lines of code in method main that creates the objects that perform the work of the application. In Chapter 3, we demonstrate many similar techniques as we introduce Java applet programming. In Chapter 4, we build on the techniques of Chapter 2 and Chapter 3 as we introduce structured programming. You will become more familiar with indentation techniques. We will study how to specify and vary the order in which statements are executed; this order is called flow of control. 2.9 (Optional Case Study) Thinking About Objects: Examining the Problem Statement Now we begin our optional, object-oriented design and implementation case study. The Thinking About Objects sections at the ends of this and the next several chapters will ease you into object orientation by examining an elevator simulation case study. This case study will provide you with a substantial, carefully paced, complete design and implementation experience. In Chapters 3 through 13, Chapter 15 and Chapter 22, we will perform the various steps of an object-oriented design (OOD) process using the UML while relating to the object- oriented concepts discussed in the chapters. In Appendices G, H and I, we will implement the elevator simulator using the techniques of object-oriented programming (OOP) in Java. We present the complete case-study solution. This is not an exercise; rather, it is an end-to-end learning experience that concludes with a detailed walkthrough of the actual Java code. We have provided this case study so that you can become accustomed to the kinds of substantial problems encountered in industry. We hope you enjoy this learning experience. Problem Statement A company intends to build a two-floor office building and equip it with an elevator. The company wants you to develop an object-oriented software-simulator application in Java that models the operation of the elevator to determine whether it will meet the company s needs. The company wants the simulation to contain an elevator system. The application consists of three parts. The first and most substantial part is the simulator, which models the operation of the elevator system. The second part is the display of this model on screen so that the user may view it graphically. The final part is the graphical user interface, or GUI, that allows the user to control the simulation. Our design and implementation will follow the so-called Model-View-Controller architecture we will learn about in Section 13.17. The elevator system consists of an elevator shaft and an elevator car. In our simulation, we model people who ride the elevator car (referred to as the elevator ) to travel between the floors in the elevator shaft, as shown in Fig. 2.22, Fig. 2.23 and Fig. 2.24. The elevator contains a door (called the elevator door ) that opens upon the elevator s arrival at a floor and closes upon the elevator s departure from that floor. The elevator door is closed during the trips between floors to prevent the passenger from being injured by brushing against the wall of the elevator shaft. In addition, the elevator shaft connects to a door on each floor (referred to as the two floor doors ), so people cannot fall down the shaft when the elevator is not at a floor. Note that we do not display the floor doors in the figures, because they would obscure the inside of the elevator (we use a mesh door to rep Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: In case you are looking for affordable webhost to host and run your web application check Vision cheap hosting services