Orientado A Objetos

Páginas: 9 (2199 palabras) Publicado: 13 de noviembre de 2012
edited from Appendix D: Introduction to RAPTOR Prelude to Programming: Concepts and Design, 5th edition by Elizabeth Drake and Stewart Venit Addison-Wesley Pub. 2011

Introduction to RAPTOR: Data Files and OOP Mode    Creating and Displaying Data Files 
 
In RAPTOR we can create data files and read from the files. However, sorting, inserting records, or merging two data files requires some fancy footwork but if you’re very ambitious, try it! 

The Redirect_Output Procedure 
To create a data file, you use a Call to the Redirect_Output procedure. RAPTOR provides  two versions of this procedure.   1. A filename is used as an argument to Redirect_Output, as shown in the following  examples:  • • Redirect_Output("sample.txt") Redirect_Output("C:\MyDocuments\John.Doe\sample")Note that in the first example, only the filename is given. In this case, the specified text file  will be created in the same directory as the current RAPTOR program. In the second  example, the full path to the file is given. Also, in the second example, no file extension is  specified. In this case, the file sample will be created with no extension. 2. You can either turn on or off Redirect_Outputby including a simple yes/true or no/false argument, as follows:  • • Redirect_Output(True)or Redirect_Output(yes) Redirect_Output(False) or Redirect_Output(no)

Now, the output must be redirected to the data file by using a Call to the Redirect_Output procedure. The name of the data file is used as the argument. This filename must be inside  quotation marks (as shown in the examples above). Next, create the code to input data. One variable is required for each field of the records in the  data file. The Output box will PUT the value of those variables into each record. For example, to 

1 of 18

edited from Appendix D: Introduction to RAPTOR Prelude to Programming: Concepts and Design, 5th edition by Elizabeth Drake and Stewart Venit Addison-Wesley Pub. 2011create a data file with records that have two fields, Name and Salary, two variables are required  (probably called Name and Salary). As values for different employees are input, each Name and Salary will be stored in the data file on a single line.   After the data has been entered, the Redirect_Output must be turned off. A Call is used to  call the Redirect_Output procedure again, but this time it’s turned off by using either no or falseas the argument.  Figure 1 (following page) shows a RAPTOR flowchart that will write two records, each with two  fields, to a data file named sample.txt. Figure 2 shows the contents of the file created (and  opened in Notepad). 

The Redirect_Input Procedure  
To display the contents of a data file, the Redirect_Input procedure is used. This works  similarly to the Redirect_Output procedure. In aCall to Redirect_Input, the filename of the file to be read is used as the argument as  follows:  Redirect_Input("sample.txt") The records are read, normally, within a loop. This is accomplished with GET statements. Input boxes are used to GET each record (in this example, the records consist of the names and  salaries). Nothing needs to be entered as a prompt. Outputboxes are used to display the output  of each record. The output is displayed in the Master Console.  

2 of 18

edited from Appendix D: Introduction to RAPTOR Prelude to Programming: Concepts and Design, 5th edition by Elizabeth Drake and Stewart Venit Addison-Wesley Pub. 2011

Figure 1 Program to write records to                           a data file

Figure 2 Text file created

 

3 of 18

edited from Appendix D:Introduction to RAPTOR Prelude to Programming: Concepts and Design, 5th edition by Elizabeth Drake and Stewart Venit Addison-Wesley Pub. 2011

The End_Of_Input Function  
RAPTOR’s built‐in function, End_Of_Input, can be used as the test condition of a loop. When  reading records in a data file, if this function is used as the test condition, RAPTOR will end the ...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • orientada a objetos
  • Que es un Objeto? Programacion Orientada a Objetos
  • Diagramas orientado a objetos
  • Modelado orientado a objetos
  • Programacion orientada a objetos
  • PROGRAMACIÓN ORIENTADA A OBJETOS EN C++.
  • Programacion orientada a objetos
  • ¿Que es la Programación Orientada a Objetos?

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS