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

  Hokusai - sketching streams in real time

You will implement and experiment with several algorithms to approximate historical item counts in a space-efficient manner.

  Anomaly and intrusion detection systems

CSC 7210 - Anomaly and Intrusion Detection Systems Executable of your program (runnable in either Windows or Unix) and Output from running your program with the provided data set - You will then evaluate the accuracy of the algorithm on the provided ..

  What is the minimum number of chopsticks deadlock freedom

Consider the variation of the Dining Philosophers problem shown in Figure where all unused chopsticks are placed in the center of the table and any philosoper.

  Illustrate the differences and similarities between the

write a 200- to 300-word short-answer response to the followingwhat are the differences and similarities between

  Calculate how many weeks it would take for the weight

Using a while loop, calculate how many weeks it would take for the weight of the first rat to become 25 percent heavier than it was originally.

  What are advantages and disadvantages of separate address

The 68000 implements negative addresses because the contents of address registers are treated as 2's-complement values. What is a negative address.

  Create application that determines cost of a discounted item

Create an application that determines the final cost of a discounted item. The interface should prompt the user for the original price of the item.

  What steps have you taken to harden systems

Discuss system hardening strategies and techniques including updates and patches, default logon/passwords, anonymous access, removal of unneeded services.

  What is the value shown by the bit string

What is the value shown by the bit string 101101 if - Negate the following binary numbers in 4-bit 2's complement representation - How large a value can be represented by each of the unsigned binary quantities?

  Write a for loop that checks whether two string arrays

Rewrite the following for loop using the "for each" construct to add the length of each String element from the data array to the totalLength.

  Determine the purpose of multiplexing in brief describe

question 1 which layers of the network model are specifically concerned with communication channel media and signaling

  Determine the access efficiency

In Problems II, if the cache access time is 100 ns, what hit ratio would be required to achieve an average access time of 500 ns?

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