Chapter 2 (Web hosting control panel) Introduction to Java Applications 87 We

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

Leave a Reply