Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new Java project in Eclipse named Lab #3 2. In your project, create a new package named utils. In the package utils, copy

Create a new Java project in Eclipse named Lab #3

2. In your project, create a new package named utils. In the package utils, copy the MyUtils.java file from Canvas Files Lab #3

3. In your project, create a second new package named asg3.

4. In the package asg3, create a new class, House.

5. In the class House declare a public (static final String) constant, DEFAULT_ADDRESS, and assign it to be the String "$$$$". Also in the class House declare another public (static final int) constant, DEFAULT_YEARBUILT, to be the value 2020.

In the class House, declare private instance variables address (String), and yearBuilt (int)

6. Inside of the class House, write the following instance methods BELOW your private instance variables:

//default constructor, creates a default House instance // receives: nothing // task : constructs a this House instance with default values for address and year built // sets address of this House instance to DEFAULT_ADDRESS // sets year built of this house to DEFAULT_YEARBUILT // example use #1: House house1 = new House(); // example use #2: House yourHouse = new House(); // example use #3: House funHouse = new House(); public House() {

} //second constructor, creates a House instance // receives: aAddress, aYearBuilt // initializes this house with received values, if invalid, uses defaults // with given data, uses default for any value that is invalid // example use #1: House house1 = new House("863 North Ridge", 2018); // example use #2: House house2 = new House("1423 ELM St. ", 2000); // example use #3: House house3 = new House("987 West Ave. ", 1950); public House(String aAddress, int aYearBuilt) {

}

// receives: aAddress, the value to use to set this instance's address to // sets this House's address after proper formatting and checking it is valid // if not valid, uses DEFAULT_ADDRESS instead, an empty string is not a valid address, must have at least 2 letters OR digits // valid addresses MUST have at least 2 letters or digits (either) and cannot be all whitespace, nor empty strings

// use utils.MyUtils.properFormat() method aAddress = utils.MyUtils.properFormat(aAddress);

// check all rules for validity

// example use #1: house1.setAddress("444 North Elm"); // stores // example use #2: someHouse.setAddress("&%^$"); //stores name as DEFAULT_ADDRESS since not 2 letters or digits in string // example use #3: funHouse.setAddress("102 great fun avenue"); // stores address as "102 Great Fun Avenue" public void setAddress(String aAddress) {

}

// sets this house's year built to be received value if // in range 1600 thru DEFAULT_YEARBUILT (inclusive) // if not in range, uses DEFAULT_YEARBUILT // fill in remaining appropriate comments public void setYearBuilt (int aYear) {

}

// fill in appropriate comments // example calls: public String getAddress() {

}

// fill in appropriate comments // example calls: public int getYearBuilt() {

}

// fill in proper comments // returns a nicely formatted String of this House with address and year built // all on same line, properly spaced and easy to see no newlines in the string public String toString() {

}

7. BE SURE YOU HAVE 3 EXAMPLE CALLS for each method in EACH METHOD's COMMENTS.

8. Create a new package in your project, name it test. Copy the file, Lab3Test.java, from Canvas cosc2425-->Files-->Lab#3-->Lab3Test.java into the test package.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Develop skills for building positive relationships.

Answered: 1 week ago

Question

Describe techniques for resolving conflicts.

Answered: 1 week ago

Question

Give feedback effectively and receive it appropriately.

Answered: 1 week ago