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

  Describe how to provide an exit button

Describe how to provide an Exit button that functions in the same way as closing the window. Should you still call set Default Close Operation on the frame?

  Find current court case involving computer crime

Summarize the case and judge for yourself if there really was a crime committed or not. Explain your reasoning based on the laws you researched for your state

  Research on three web analytics tools available to business

Compare the main features of each and suggest the best tool in your opinion for a small to medium sized business.

  Write the pseudocode for performing a currency conversion

Write the pseudocode for performing a currency conversion from pennies to other forms of currency in addition to any remaining pennies.

  In addition you must simplify administration tasks for the

envision that you are a systems administrator managing five different web servers for your company. each web server

  Write a scheme procedure shift_left that transforms

Write a Scheme procedure (count a lst) that counts the number of times a element a occurs in a list.

  What are two processes of conserving ip addresses

How are default subnet masks determined.What are two processes of conserving IP addresses? Explain these methods.

  Describe how do the teams manage their team boundaries

Describe How do the teams manage their team boundaries? What are the trade-offs between internal cohesion and external ties within each type of team?

  Discuss establish a ranking of vulnerabilities in a system

Why is it important to establish a ranking of vulnerabilities in a system? Use examples to show vulnerability priorities in action

  How the digital forensics function complements

Describe how the digital forensics function complements the overall security efforts of the organization. Evaluate the operational duties of digital forensic.

  Depiction of situation with flow chart

Physical goods are shipped back to supplier if they are discovered to be damaged upon arrival at the receiving warehouse.

  Distinguish between passive and active security attacks

Distinguish between passive and active security attacks. Name some passive attacks. List and define live scanty services discussed in this chapter.

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