Saturday, December 11, 2010

IT311 - OOP Laboratory Exercise 5

Java Laboratory Exercise 5

Instructions:

  • Due: December 15, 2010 11:59 pm.
  • Send the class file and the main program (Household.java and TestHousehold.java)
  • Attach and email the files in celticguardiandancingelf@yahoo.com
  • Subject: Lastname__it311_labexer5

a.) Create a class named Household that includes data fields for the number of occupants and the annual income, as well as methods named setOccupants(), setIncome(), getOccupants(), and getIncome() that set and return those values respectively. Additionally, create a constructor that requires no arguments and automatically sets the occupants field to 1 and the income field to 0. Save this file as Household.java.

b.) Create a program named TestHousehold that demonstrate that each of the methods works correctly.

c.) Create an additional overloaded constructor for the Household class you created. This constructor receives an integer argument and assigns the value to the occupants field. Add any needed statement to TestHousehold to ensure that the overloaded constructor works correctly.

d.) Create a third overloaded constructor for the Household class you created. This constructor receives two arguments, the values of which are assigned to the occupants and income fields, respectively. Alter the TestHousehold program to demonstrate that each version of the constructor works properly.

1 comments:

glaiglay December 12, 2010 at 4:57 PM  

Charmuz na au ka Sir Mark...

Naa ka uyab Sir Mark? :))

About

My photo
Hi! Mabuhay everyone! I am Mark Van M. Buladaco! I am from Davao City! Hope you enjoy my blog!

Contact me

476 alley Malvar St., Davao City, Philippines
celticguardiandancingelf@yahoo.com
Web Marketingdrive recovery software