联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> javajava

日期:2018-09-03 01:26


SENG1110/SENG6110 Object Oriented Programming

Attention: use only Bluej to edit, compile, run and debug your programs. It will be very useful in the future in

SENG1110/6110 and subsequent courses to know how to use an IDE. The most important aspect is to know how to

debug a program using an IDE. You have seen a video about it in the last computer lab. Today you will have some tasks

involving debugging.

1. Download the codes Person.java, Couple.java and AgencyInterface.java from Blackboard. Listen the video. Now

follow the instructions below. Note that the instructions from a. to f. are the same from the previous tutorial. The

instruction g. will show you how to debug a program.

a. Execute Bluej. Just write bluej in the command line.

b. Open a new project:

i. select open from project menu

ii. write agencyExample (it will be created a folder agencyExample and all programs related to this

project will be inside the folder agencyExample)

c. Add each class from a file

i. Select add class from file from edit menu

ii. Select the file Person.java (repeat the process for Couple.java and AgencyInterface.java)

d. To edit your codes, just click twice in a class and the source code will open

e. To compile, just choose the compile menu.

f. To run the program

i. go to Bluej window (in AgencyInterface.java window – the class that has the method main).

ii. use the right button of the mouse and choose main(). Don’t worry about the other options now.

g. To debug the program

i. Select show debug from view menu

ii. Go to AgencyInterface.java and click in the left of the line System.out.print("her name: ");. A symbol

stop should appear. If does not appear is because you should go more to the left.

iii. Now run again as indicated in step f

iv. The program will run and stop in the line with the stop.

v. Now you can run each line clicking the Step or Step Into buttons and see the variables values in

debug window. The difference between these two buttons is Step Into will enter inside a method

and Step will not. Use Step Into and you will go inside each object.

vi. You can add more stops if necessary and you can delete a stop just clicking in the stop symbol.

vii. Note that during this process you can see the values inside the variables.

h. (you need to complete this exercise (only h.) and show, using BlueJ - debug, the result to your

demonstrator)

Add the following feature in the AgencyInterface class. The age needs to be greater or equal to 18. If age is

less than 18, the program will ask again, until the input is a number greater of equal to 18. You should

implement a method called inputAge and call the method from main. The method will be as:

public static int inputAge()

{

// add the code here to receive an integer number as input and

// check if the number is greater or equal to 18

// if the number is less than 18, the program should ask the number again

// until the input number is greater or equal to 18

}

i. Debug the code from h (if you haven’t done yet) line by line and check the value of each variable using

BlueJ.

j. Add a method in Couple class called printCouple(). The method should return a String with the name and

age of each person. Call the method in AgencyInterface.

SENG6110


版权所有:留学生程序网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。