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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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