Ask Computer Engineering Expert

Objectives - practice the following concepts:

  • ArrayList of objects as the "internal database" - referred to below as the DB [NOTE: This is NOT a true database in terms of what we usually means in computing, managed by a database management system like MySQL or Oracle]
  • "Rapid Prototyping" to develop a program which is easily expandable in the future
  • User options menu
  • Input data from both a file and interactive user
  • Reading/Editing of user input (done in setters)
  • "Automatic" loading/saving of backup file data from/to the internal DB at the start/end of the program
  • Using the same file name for input file and output file (so output over-writes input file - CAUTION !!!)
  • Searching the DB for a single matchand for multiple matches
  • Adding and removing data from the DB

PROJECT BACKGROUND   A family friend wants you to develop a quick prototype program to help her keep track of the houses/condos she's looking at in her search to buy a new home.  You'll likely expand the program in the future (not in CS1110) to add such things as:

  • other data fields for each house
  • capability to search on other fields
  • betterediting, repeatedly asking user for correct data, etc.
  • adding pictures as fields
  • changing the internal "database" to EXTERNAL storage structures like hash files and indexed files instead (in CS3310 - Data & File Structures)
  • changing the storage structure to use an ACTUAL DATABASE using actual database management system software instead (in CS4430 - Database Systems) like MySQL or Oracle to store/access the data

PROJECT OVERVIEW (for asgn 8)This OOP program keeps a DBof houses for searching/updating/printing by the interactive user.  The data is stored in a .csv file for permanent storage while the program is NOT running.  It is automatically loaded into internal storage, the DB, (the ArrayList of objects) when the program starts, so that it can be searched more quickly.  The user is repeatedly presented with a menu of search (and other) options, which the program handles for them.   When the user is finished, the DB is dumped back to the same .csv file, since there may now be additional houses in the DB, or houses which were removed from the DB. 

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The DB MUST be implemented as an ArrayList of House objects.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

DATA FILEHouseDB.csvNo header record.  The data here needs no cleaning/editing (unlike the data from the user for option 5 which DOES need cleaning/editing).  Each record contains these fields in this order:

                stAdr                      -street address uniquely identifier a particular house or condo

                city                         

sqFt                         - a positive integer between 100-5000 inclusive

numBR                   - number of bedrooms - a positive number between 0-5 inclusive

price                       - selling price - a positive integer between 10000 and 300000 inclusive

 

CAUTION !!!This file is both the INPUT file and the OUTPUT file.  So while you're testing, you should write to a DIFFERENT OUTPUT FILE - otherwise you'll keep LOSING your INPUT FILE DATA.   Once your program works, change the output file name to be the same as the input file.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * *

THE MENU OF QUERY OPTIONS

The menu is repeatedly presented to the user.  Use JOptionPane windows for user interaction.  Menu includes:

1)       search by street address (which uniquely identifies a particular house/condo - so results in 0 or 1 hit)

2)       search by size (which results in 0/1/many hits)

3)       search by number of bedrooms (which results in 0/1/many hits)

4)       list all houses

5)       add a new house

6)       remove a house

7)       done querying DB

The program then provides the user with the appropriate response.

Other INPUT the user provides (when prompted):

                For option 1          - street address (like 123 Hardy)

For option 2          - number of square feet (the threshold like 1400)

                                                                AND whether they want larger (>=) or smaller (<=) than that threshold number

For option 3          - number of bedrooms (like 3, or 0 for a studio type condo)

For option 5          - the following fields (separately):    stAdr, city, sqFt, numBR,  price

For option 6          - street address

 

Output (prompts) to user - in JOptionPane windows:

                For option 1/2/3/4              - the prompts to get the user input (see above)

                For option 5                          - the 5 prompts for the 5 fields (individually)

                For option 6                          - the prompt for the street address

 

Output (responses) to user - to the Console Window:

[NOTE:  I'm showing specific addresses, etc. just to demo the format.  Use the address/sqFeet/etc. that the user specified for the query]

                For option 1                          - TARGET:  12 Miller Rd.

For option 2                          - TARGET:  >= 1,400 sq. feet

For option 3                          - TARGET:  3 bedrooms

For option 4                          - LIST OF ALL HOUSES                    

For option 1/2/3/4              - all 5 fields nicely formatted (some spacing between fields,

include , in sqFt, include $ and , in the price)

                For option 5                          - reassurance message:      OK, house at 15 Fulton St. added

                For option 6                          -reassurance message:       OK, house at 2 Main St.removed

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

EDITING INPUT DATA:

A.       The data in the FILEis already correct - so put this data in the DB by using the object constructor (5 parameters) for each object (house) you create.

B.       The data from the interactive USER needs editing before it's stored.  So use the 5 setters for this.  Each setter

1)       uses a DialogBoxwindow (with prompt) to get the data from the user

2)       For sqFt, numBR, price fields

a.        checks that the user data is numeric/positive/integer/withinRange:

That is:                   sqFt         - a positive integer between 100-5000 inclusive

numBR   - a positive number between 0-5 inclusive

price       - a positive integer between 10000 and 300000 inclusive

b.       If data is wrong, itdisplays a MessageBox window indicating there's an error and what DEFAULT VALUE the program will automatically use:

That is:                   sqFt         - 1500

                                numBR   - 2

                                price       - 150000

3)       Stores the data in the instance variable

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

PROGRAM STRUCTURE

4 .java files for these 4 classes (containing the methods specified - perhaps additional methods too)

1)       The main program containing the main method, showMenu method                                                           

2)       A Utility class with2 static methods:  loadFileToDB and dumpDBToFile                                              

3)       A QueryHandler class of 6 static methods, one for each of the first 6 options:                                                       doAddressSearch, doSizeSearch, doBRSearch,                           listHouses, addHouse, removeHouse

4)       The OOP House class contains:   instance variables,

setters (for user data editing/setting), a constructor (for file data "setting"),

toString method (prepares a .csv record for file),   prettyPrint method (for option 1/2/3/4 printing)

NOTE:  Any of these classes could contain additional methods to further modularize the program.

Attachment:- HouseDB.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92394886
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As