3.13 Tutorial 2
Tasks
-
Consider the project figures. Indicate which are the fields of the classes
Square
,Circle
, andPerson
, and their corresponding types. -
Open BlueJ, and load the figures project. Using the Code Pad, create a circle and a rectangle, and display both on the screen. Call methods
slowMoveHorizontal
andslowMoveVertical
on these objects from the Code Pad, to get familiar with the syntax of methods and parameter passing. -
Load the house project. Modify the method
draw
in classPicture
, so that the sun sets slowly. The sun is represented by a circle, and this class has methods that allow a figure to move slowly; you may use these methods to achieve the required behavior. -
Modify the method
draw
in classPicture
again to achieve a behavior in which the sun moves slowly to the left until it disappears, and appears again on the right, stopping at the same position where it started.u -
Do exercises 1.19 and 1.20 from Objects First with Java: A Practical Introduction using BlueJ (Barnes & Kölling).
-
Load the lab-classes project. Create various objects of class
Student
, passing adequate values as parameters to the constructor to represent real students of this course. Take into account that all parameters are of typeString
, and string literals are indicated between double quotes. -
Describe the fields of class
Student
and their corresponding types. -
Enumerate at least two methods of class
Student
whose return type is notvoid
, and describe in your own words what these methods do. -
Create instances of class
LabClass
to represent different labs of this course. Use the methodenrollStudent
to add students to the labs. Analyze the fields and methods in theLabClass
class to assign a teacher to each lab, a room, and a time, with some realistic values. -
Invoke the method
printList
on theLabClass
instances to obtain the details of each lab.