Closed

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

Skills: Java

See more: test iteration, steps to write a report, session 13, print println java, operator code, objective c programs, method to write a report, learn java code, how to write a summary report, how to write an objective, how to learn how to code, first class objects in java, code programs, java to objective c, how long to learn java, learn objective c, update java code, type 1500, remove object, name three programs, learn java, java c, condo, c java, c c java

About the Employer:
( 0 reviews ) United States

Project ID: #1679146

41 freelancers are bidding on average $275 for this job

dobreiiita

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

$250 USD in 1 day
(157 Reviews)
6.3
procoder898

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

$250 USD in 0 days
(77 Reviews)
6.0
it2051229

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

$250 USD in 0 days
(158 Reviews)
6.0
diepbp

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

$250 USD in 5 days
(71 Reviews)
5.9
samitXI

Please check your inbox. Thanks

$300 USD in 2 days
(63 Reviews)
5.7
rhkchathuranga

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

$250 USD in 2 days
(24 Reviews)
5.5
manhpham

I can do this in 1 day

$250 USD in 1 day
(13 Reviews)
4.0
javabee4u

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

$250 USD in 0 days
(3 Reviews)
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 in 3 days
(14 Reviews)
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 in 4 days
(9 Reviews)
3.4
coderz01

Hello. I are you still interested in this project.

$250 USD in 1 day
(4 Reviews)
3.1
tauitdnmd

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

$250 USD in 1 day
(6 Reviews)
3.1
euphern

Hi, Please check PMB. Thanks

$250 USD in 0 days
(2 Reviews)
3.0
huzaifaatlancer

check your pm!

$250 USD in 3 days
(2 Reviews)
2.5
vernonsullivan

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

$250 USD in 1 day
(2 Reviews)
1.9
mtchinthaka

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

$250 USD in 2 days
(2 Reviews)
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 in 1 day
(1 Review)
2.3
dsingh87

We have a group of Java freelancer developer and we are devloping J2EE application too.we can make this very easily if U r intersted we can proceed

$250 USD in 5 days
(0 Reviews)
0.0
sebestian1993

I can finish this project, even if I'm not chosen can you please send me the task as I would like to challenge myself by finishing this program.

$250 USD in 1 day
(0 Reviews)
0.0
vishalranapariya

i am working in R&D in JAVA. I ma develop to many application in java and j2ee.

$270 USD in 2 days
(0 Reviews)
0.0