Question: Java Programming Objectives Develop subclasses for an existing class thereby illustrating inheritance And the usual submission and IDE objectives General Instructions You will develop two

Java Programming

Objectives

Develop subclasses for an existing class thereby illustrating inheritance

And the usual submission and IDE objectives

General Instructions

You will develop two subclasses of the parent Place class. You will upload all relevant files to this lab for grading. You will need the code from Program 4a to complete this lab.

Instructions for Attraction.java

Write a Java program Attraction.java that has the following characteristics.

extends Place

New attributes: type (int), price (double)

New Methods:

public Attraction(String name, String desc, double latitude, double longitude, double price, int type) where for type values: - 0 is an amusement park - 1 is an aquarium - 2 is a zoo

public double getPrice() -- returns current price

public int getType() -- returns type

public boolean hasAnimals() -- returns true if type contains "zoo" or "aquarium"

public void toString() -- overrides superclass toString() method so that: - second line: print tab character, "Tickets average $xx.xx" and, if hasAnimals() is true, "and feature exciting animals". Examples:

Seaport Village (latitude:32.70872,longitude:-117.171) Tickets average $55.00 San Diego Zoo (latitude:32.73607,longitude:-117.14927) Tickets average $55.00 and feature exciting animals 

Instructions for Eatery.java

Write a Java program Eatery.java that has the following characteristics:

extends Place

New attributes:

cost (double)

cuisine (String)

starRating (int)

New Methods:

public Eatery(String name, String desc, double latitude, double longitude, String cuisine, double cost, int starRating)

public double getCost() -- returns current cost

public String getCuisine() -- returns current cuisine

public int getRating() -- returns current starRating

public String ratingToStars() -- returns string containing one '*' character for each value (1 to 5)

public String getCostToSymbols() -- returns '$' characters that correspond to cost [Note: no spaces--ZyBooks MarkDown text doesn't allow four dollar signs in a row. Grrr! ] - if cost is less than 25.0, $ - if cost is less than 50.0, $$ - if cost is less than 75.0, $$$ - if cost is less than 100.0, $$ $$ - if cost is greater than or equal to 100.0, $$ $$+

public String toString() -- overrides superclass toString() method so that: - second line: print tab character, "Price: $xxx" where xxx corresponds to cost - third line: print tab character, print "Rating: *xxx" where xxx corresponds to starRating

The Cottage (latitude:32.84341,longitude:-117.275) Price: $$$ Rating: **** 

Turning in the assignment

When you are satisfied with the program (or are out of time and want some partial credit), submit the following files: 1) Place.java (unchanged from Program 4a) 2) GeoLocation.java (unchanged from Program 4a) 3) Eatery.java 4) Attraction.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!