Write an application in java that models an evening stroll

Assignment Help Computer Engineering
Reference no: EM132192964

Question :

Write an application in java that models an evening stroll on a street containing several buildings, some of which are haunted. Make sure your application compiles and runs correctly.

The buildings on the street should be modelled using an abstract Building class, which is extended by concrete House and Asylum subclasses. Each building has a double variable for its size and a boolean variable indicating whether or not it is haunted. In addition, each House (but not each Asylum) has some specific feature which is described by a String variable (for example, "charming fireplace" or "updated kitchen".) An Asylum (but not a House) also has a String variable for its name (e.g., "State Home For The Criminally Insane.")

House and Asylum need constructors. You need getters and setters for the other variables; think about which ones should be in Building and which ones should be in the concrete classes.

Each building has an explore() method, but they are different in House and Asylum. House's explore() prints out the size of the house and information about its special feature. Asylum's explore() prints the name of the Asylum and its size. Each explore() method also warns the user if the building is haunted by printing a message like "Watch out! A ghost!"

The street is modelled by a Street class which has a name, a constructor, a list of Buildings, a way to add a Building to the list, a getter for the street name, and a getNumHaunted() method, which returns an int indicating how many of the Buildings in the list are haunted.

Street must also have a stroll() method. Stroll() prints a message like "Let's go for a stroll on Maple Street," using Street's getter to get the actual name of the street, then then iterates through the list of Buildings, calling each Building's explore() method. It then uses getNumHaunted() to show how many of the Buildings are haunted.

Finally, use a driver class to instantiate a Street, add five houses and one asylum to it, and then call Street's stroll() method. Here is sample output:

Let's go for a stroll on Maple street!

You pass a 165.4 sq. meter house with a(n) updated kitchen

Watch out! A ghost!

You pass a 208.75 sq. meter house with a(n) charming fireplace

You pass a 171.5 sq. meter house with a(n) capacious septic tank

You pass a 35000.25 sq. meter asylum called The California Home For People Who Like Cats

Watch out! A ghost!

You pass a 211.4 sq. meter house with a(n) beautiful lawn

You pass a 301.0 sq. meter house with a(n) bonus room

Watch out! A ghost!

3 of the buildings on Maple street are haunted.

Reference no: EM132192964

Questions Cloud

An algorithm that takes an array of any size : Write an application in Java which includes an algorithm that takes an array of any size, selects the high and low integer from the array of integers.
Write an application that accepts a users password : Write an application that accepts a user's password from the keyboard. When the entered password is less than six characters, more than 10 characters.
Write an algorithm to solve the independent set problem : Write an algorithm to solve the Independent set problem. In English describe the way the input is given; the output; your assumptions etc.
Find the smallest number in an array of n numbers : Find the smallest number in an array of n numbers. Determine if any number appears twice in an array of n numbers without sorting the array.
Write an application in java that models an evening stroll : Write an application in java that models an evening stroll on a street containing several buildings, some of which are haunted.
Write a an application arithmetic which gets input : Write a an application Arithmetic which gets input from the user. It will have a main method. You will write the whole class
Finding the rth largest element in the set of s by calling : Write the function SELECTLargest(S,r) for the finding the rth largest element in the set of S by calling the function SELECTSmallest.
Display a button labeled reverse and two text fields : Write an application with a GUI that displays a button labeled Reverse and two text fields.
Write an algorithm to sort a linked list of integer : Write an algorithm to sort a linked list of integer as follows: Find the largest value in the list.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Explain of how they may be used in an organization

Identification of features to be used as-is, possible modifications and additions.explain of how they may be used in an organization.

  Describe one hardware component in detail

Describe one hardware component that are essential to YOU as a consumer. Provide three options (brand, style, etc.) for the component.

  Write a program that uses an if-else construct

Write a program that uses an if-else construct to check for a leap year. Use a do-while loop to divide a number repeatedly by 2 and print the remainder.

  Write an interactive program that requires the mechanic

Wright's Garage wants an interactive program that requires the mechanic to enter the tire pressure from four tires on any given car that comes into the garage.

  The camera system and a cop walking around

A company in the Netherlands that makes navigation devices collects location data from the devices to provide real-time services to its customers.

  What problems might same port has a different name cause

In the same port has a different name in different processes. What problems might this cause? What is this system call good for?

  Computer rendering of stochastic models

Prepare a slideshow on Computer rendering of stochastic models

  Define web traffic must flow via organizations web proxy

A common management requirement is that "all external Web traffic must flow via the organization's Web proxy.

  Describe the real-world system and the architectural style

Describe the real-world system and the architectural style. Justify why this architectural style is well-suited for the selected real-world system.

  Calculate the daily average distance walked by the user

Using Java, how can I use a loop that runs 7 times (using the final variable) to ask and get how many steps the user walks each day of the seven days.

  Question1 add following 16-bit 2s complement numbers

question1 add following 16-bit 2s complement numbers represented in hex assume word size of computer is 16 bits - fe59

  Define how the given impacts have been good or bad

You think that more parents need to be aware of the impact of technology, including social networking, on society. You decide to write a short article.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd