lunes, 18 de febrero de 2008

ejercicios en blue j (1.17al 1.27)

  • Exercise 1.17

Create an object of class Student. You will notice that this time you
are prompted not only for a name of the instance, but also for some other parameters.
Fill them in before clicking Ok. (Remember that parameters of type String must be
written in double quotes.)

El ejercicio dice que debemos:
Crear un objeto de la clase Estudiante. Usted se dará cuenta de que esta vez usted Se impulsó no sólo por un nombre de la instancia, pero también para algunos otros parámetros.
Llenarlos antes de hacer clic en Aceptar. (Recuerde que los parámetros de tipo String debe ser Escrito entre comillas dobles.)

Primero abrimos el proyecto LAB- CLASSES

Al dar clic derecho en la clase student elegimos new Student

Nos aparece una ventana en la cual nos pide valores como:

Nombre de la instancia, los datos del nuevo estudiante (nombre, ID).La cual llenamos

Al dar OK se creo el objeto.

  • Exercise 1.18

Create some student objects. Call the getName method on each
object. Explain what is happening.

Ejercicio 1,18
Cree algunos objetos Student. Llame al método getName en cada Objeto. Explique lo que está sucediendo

Creamos mas objetos


después llamamos el metodo getName en cada objeto y nos aparecio una ventana como esta:
Donde aparece el nombre del estudiante, que nosotros le pusimos al llenar los datos.






  • Exercise 1.19

Crear un objeto de clase LabClass. Como indica la firma, Necesita especificar el número máximo de alumnos en la misma clase (un entero).

  • Exercise 1.20

Call the numberOfStudents method of that class. What does it do?

Llame al metodo numberOfStudents de esa clase. ¿Para qué?

  • Exercise 1.21

Look at the signature of the enrollStudent method. You will notice
that the type of the expected parameter is Student. Make sure you have two or three
students and a LabClass object on the object bench, then call the enrollStudent
method of the LabClass object. With the input cursor in the dialog entry field, click
on one of the student objects – this enters the name of the student object into the parameter
field of the enrollStudent method (Figure 1.8). Click Ok, and you have added
the student to the LabClass. Add one or more other students as well.

Vea la firma del metodo enrollStudent . Usted notará Que el tipo de parámetro es la espera de Estudiantes. Asegúrese de tener dos o tres LabClass estudiantes y un objeto sobre el objeto de banco, y luego llamar a la enrollStudent Método de la LabClass objeto. Con el cursor de entrada en el campo de entrada de diálogo, haga clic en uno de los objetos de estudiantes - esto entra en el nombre del estudiante objeto en el parámetro Ámbito de la enrollStudent método (Figura 1.8). Haga clic en Aceptar, y que ha añadido Al estudiante a la LabClass. Añadir una o más estudiantes también.


  • Exercise 1.22

Call the printList method of the LabClass object. You will see a
list of all the students in that class printed to the BlueJ terminal window (Figure 1.9).
Ejercicio 1,22
Llame a la printList método de la LabClass objeto. Verá una Lista de todos los estudiantes en la clase que imprime al BlueJ ventana de Terminal.



Exercise 1.23
Create three students with the following details:


Snow White, student ID: 100234, credits: 24
Lisa Simpson, student ID: 122044, credits: 56
Charlie Brown, student ID: 12003P, credits: 6


Then enter all three into a lab and print a list to the screen.


Crear tres alumnos con los siguientes datos: Blanca Nieves, estudiante ID: 100234, créditos: 24 Lisa Simpson, estudiante ID: 122044, créditos: 56 Charlie Brown, estudiante ID: 12003P, créditos: 6 A continuación, introduzca los tres en un laboratorio y de imprimir una lista en la pantalla.

Exercise 1.24
Use the inspector on a LabClass object to discover what fields it has.
Utilice el inspector en una LabClass objeto de descubrir lo que los campos que tiene

Exercise 1.25
Set the instructor, room, and time for a lab, and print the list to the
terminal window to check that these new details appear.
Conjunto de instructor, habitación, y el tiempo para un laboratorio, y de imprimir la lista a la Ventana de terminal para comprobar que estos nuevos datos aparecen.

Exercise 1.26
In this chapter we have mentioned the data types int and String.
Java has more predefined data types. Find out what they are and what they are used
for. To do this, you can check Appendix B, or look it up in another Java book or in an
online Java language manual. One such manual is at
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/
datatypes.html

Exercise 1.27
What are the types of the following values?
0
"hello"
101
–1 :
True
"33"
3.1415

¿Cuáles son los tipos de los siguientes valores?
"hello" STRING
101 INT
–1 LONG
True BOOLEANO
"33" STRING
3.1415 DOUBLE




No hay comentarios: