Đã Đóng

Java Programs

11:45 PM PST 6/5/2012

Objective: To learn how to use an inner class, object-type class attributes, StringBuffer, null values, and self-referential classes.

Steps:

(i) Create a new folder called 'assign72' under C:\Java\Lesson7. Copy all files (except [url removed, login to view]) of assign 7.1 into this folder.

(ii) Modify classes as follows:

Class Name: Home

Attributes:

• Remove the attributes: 'value' and 'commission'

• Add a new attribute called 'hd' of type: HomeDerivedData

• Add a new attribute called 'nextHome' of type: Home

Constructor:

• constructor (homeType, age, sqft):

Modify this constructor to instantiate an object of the inner class HomeUtil and call computeDerivedData() on it, to update the 'hd' class attribute.

Set 'nextHome' attribute to 'null' (without the quotes). Note that null is valid to use as a value of any object, and means the object is 'undefined'.

Methods:

• Getters for all attributes

• Setter for 'nextHome' attribute only

Inner Class: Class Name: HomeUtil

Methods:

• Copy computeDerivedData() method from [url removed, login to view] of assign 7.1 into this inner class, and modify it so that it doesn't take any input parameters and has a return type of 'void'. Inside the method body, update the 'hd' attribute of the Home class, to set its 'value' and 'commission', using same formulae as in assign 7.1.

Class Name: HomeType

Attributes:

No change

Constructor:

No need to implement any constructor (as before)

Methods:

• Modify getTypeDescr() to return a StringBuffer instead of a String

Class Name: HomeDerivedData

Attributes:

No change

Constructor:

Add a default constructor

Methods:

No change

NOTE: [url removed, login to view]: NOT to be used anymore

(iii) Modify the TestHome test driver so that it instantiates three Home type objects, as follows:

• Home object # 1: Type: Single Family, age = 15 yrs, and sqft = 2000.

• Home object # 2: Type: Condo, age = 8 yrs, and sqft = 1500.

• Home object # 3: Type: Twon Home, age = 10 yrs, and sqft = 2500.

The 'nextHome' for Home object # 1 should be Home object # 2; similarly, the 'nextHome' for Home object # 2 should be Home object # 3. To achieve this, call setNextHome() on Home object # 1, sending it Home object # 2. Similary, call setNextHome() on Home object # 2, sending it Home object # 3.

Write a static method called 'printReport()' that takes a Home object, and a 'homeNbr' parameter of type: int. This method should print the content of the Home object (same as in assign 7.1, except that now the title for each home should include the home nbr. For example, for Home object # 1, it should say "Summary Report for Home # 1", and so on. Begin by copying the [url removed, login to view] lines from [url removed, login to view] of assign 7.1 into this method. Replace all [url removed, login to view] lines with String concatenation using the += operator, each time adding one line of output. Do NOT use one long String to concatenate all pieces, instead use += operator for each attribute of the Home object, and a SINGLE [url removed, login to view]() at the end of the method to dump the resulting String containing the full report for the Home object.

Inside main(), declare a temporary Home type object called 'hTmp', and assign it the first Home object. Declare a loop index called 'i' and initialize to 1. Then use a while loop that loops as long as hTmp is not null. In each iteration of the loop, call 'printReport()' passing it the 'hTmp' object and a home nbr (the loop index), then set 'hTmp' to be the next Home object each time. Increment 'i' at the end of the loop.

(iv) Compile [url removed, login to view], [url removed, login to view], [url removed, login to view], and then [url removed, login to view] and run the code. Verify that the output session looks similar to this:

C:\Java\Lesson7\assign72>javac [url removed, login to view]

C:\Java\Lesson7\assign72>javac [url removed, login to view]

C:\Java\Lesson7\assign72>javac [url removed, login to view]

C:\Java\Lesson7\assign72>javac [url removed, login to view]

C:\Java\Lesson7\assign72>java TestHome

Summary Report for Home # 1

Type: Single Family

Age: 15

Kỹ năng: Java

Xem thêm: test iteration, steps write report, session 13, print println java, operator code, objective programs, method write report, learn java code, write objective, code programs, java objective, long learn java, learn objective, void, update java code, type 1500, remove object, name three programs, learn java, java c, condo, concatenate, c programs, c java, java means

Về Bên Thuê:
( 0 nhận xét ) United States

Mã Dự Án: #1679146

41 freelancer đang chào giá trung bình $275 cho công việc này

dobreiiita

Hi, I am JAVA expert and can surely help you here, Please check your inbox,Thanks

$250 USD trong 1 ngày
(157 Đánh Giá)
6.3
procoder898

Hi, I am expert at Java and can surely satisfy you. Please check your inbox,

$250 USD trong 0 ngày
(77 Đánh Giá)
6.0
it2051229

Hi, kindly check your inbox for my inquiries. Thanks.

$250 USD trong 0 ngày
(158 Đánh Giá)
6.0
diepbp

I am confident to handle your project. Please check your inbox for details, thank you.

$250 USD trong 5 ngày
(71 Đánh Giá)
5.9
samitXI

Please check your inbox. Thanks

$300 USD trong 2 ngày
(63 Đánh Giá)
5.7
rhkchathuranga

I have lot of experience in Java Programming, Please check your P.M.B. sir........

$250 USD trong 2 ngày
(24 Đánh Giá)
5.5
manhpham

I can do this in 1 day

$250 USD trong 1 ngày
(13 Đánh Giá)
4.0
javabee4u

Hi, I am ready to help on Inner class, String Buffer, Object-type attributes and self-referential classes. Thanks

$250 USD trong 0 ngày
(3 Đánh Giá)
3.9
diamond1027

Hello, I'm interested in your project. I can start just now and finish perfectly this project. I'm sure, you would satisfy, if I will work with you. Regards.

$250 USD trong 3 ngày
(14 Đánh Giá)
3.8
khiemdmse60773

Hi, I am an expert in Java, so It would be great for me to help you with this project.

$250 USD trong 4 ngày
(9 Đánh Giá)
3.4
coderz01

Hello. I are you still interested in this project.

$250 USD trong 1 ngày
(4 Đánh Giá)
3.1
tauitdnmd

Dear sir. I can do this for you .Pls check your pmb

$250 USD trong 1 ngày
(6 Đánh Giá)
3.1
euphern

Hi, Please check PMB. Thanks

$250 USD trong 0 ngày
(2 Đánh Giá)
3.0
huzaifaatlancer

check your pm!

$250 USD trong 3 ngày
(2 Đánh Giá)
2.5
vernonsullivan

Hello, the tasks are simple and I can fully guarantee good coding and also good comments. Cheers.

$250 USD trong 1 ngày
(2 Đánh Giá)
1.9
mtchinthaka

Hello Sir, I am very confidence to handle this work very easily. Please check PM

$250 USD trong 2 ngày
(2 Đánh Giá)
1.0
santoshsoftware

Hi, I am Oracle certified Java SE 6 Programmer, 7 years of experience in Java EE, Java SE, and Databases. I can do this job.

$250 USD trong 1 ngày
(1 Đánh Giá)
2.3
eggadi114

working more than 10 years on java

$250 USD trong 6 ngày
(0 Đánh Giá)
0.0
i86

Hi, I am a graduated SE and like to work on this project. I have worked in similar type of java assignments as an undergraduate. So I can help you with this. Thanks!

$250 USD trong 3 ngày
(0 Đánh Giá)
0.0
sunilr1

Thank you for considering me.

$250 USD trong 4 ngày
(0 Đánh Giá)
0.0