Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA help ASAP please Instructions for Attraction java Write a Java program Attr

ID: 3846905 • Letter: J

Question

JAVA help ASAP please

Instructions for Attraction java Write a Java program Attraction. java that has the following characteristics. extends Place New attributes: o type (int o price (double) New Methods: o 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 o public double getPrice0 returns current price o public int get Type0-returns type o public boolean hasAnimals0-returns true if type contains "zoo" or "aquarium" o public void toString0 overrides superclass toString0 method so that: second line: print tab character, Tickets average $xxxx" and, if hasAnimals is true, "and feature exciting animals". Examples Seaport Village (latitude 32.70872, longitude 17.171) Tickets average $55.00 San Diego Zoo latitude 32.73607, longitude -117.14927) Tickets average $55.00 and feature exciting animals

Explanation / Answer

Here is your answer: -

Attraction.java

public class Attraction extends Place {
   private int type;
   private double price;

   public Attraction() {

   }

   public Attraction(String name, String desc, double latitude, double longitude, double price, int type) {
       super(name, desc, latitude, longitude);
       this.type = type;
       this.price = price;
   }

   public int getType() {
       return type;
   }

   public void setType(int type) {
       this.type = type;
   }

   public double getPrice() {
       return price;
   }

   public void setPrice(double price) {
       this.price = price;
   }

   public boolean hasAnimals() {
       if (this.type == 1 || this.type == 2) {
           return true;
       }
       return false;
   }

   @Override
   public String toString() {
       if (this.hasAnimals())
           return super.toString() + " Tickets average $" + this.price + " and feature exciting animals";
       else
           return super.toString() + " Tickets average $" + this.price;
   }

}

Place.java

public class Place {
   private String name;
   private String desc;
   private double latitude;
   private double longitude;
  
   Place() {
      
   }
  
  
   public Place(String name, String desc, double latitude, double longitude) {
       this.name = name;
       this.desc = desc;
       this.latitude = latitude;
       this.longitude = longitude;
   }


   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public String getDesc() {
       return desc;
   }
   public void setDesc(String desc) {
       this.desc = desc;
   }
   public double getLatitude() {
       return latitude;
   }
   public void setLatitude(double latitude) {
       this.latitude = latitude;
   }
   public double getLongitude() {
       return longitude;
   }
   public void setLongitude(double longitude) {
       this.longitude = longitude;
   }


   @Override
   public String toString() {
       return this.name+" (latitude:"+this.latitude+",longitude:"+this.longitude+")";
   }
  
  
}

Eatery.java

public class Eatery extends Place {
   private double cost;
   private String cuisine;
   private int starRating;

   public Eatery(String name, String desc, double latitude, double longitude, String cuisine, double cost,
           int starRating) {
       super(name, desc, latitude, longitude);
       this.cost = cost;
       this.cuisine = cuisine;
       this.starRating = starRating;
   }

   public double getCost() {
       return cost;
   }

   public void setCost(double cost) {
       this.cost = cost;
   }

   public String getCuisine() {
       return cuisine;
   }

   public void setCuisine(String cuisine) {
       this.cuisine = cuisine;
   }

   public int getStarRating() {
       return starRating;
   }

   public void setStarRating(int starRating) {
       this.starRating = starRating;
   }

   public String ratingToStars() {
       String s = "";
       for (int i = 0; i < this.starRating; i++) {
           s = s + "*";
       }
       return s;
   }

   public String getCostSymbols() {
       if (cost < 25.0) {
           return "$";
       } else if (cost > 25.0 && cost < 50.0) {
           return "$$";
       } else if (cost > 50.0 && cost < 75.0) {
           return "$$$";
       } else if (cost > 75.0 && cost < 100.0) {
           return "$$ $$";
       } else {
           return "$$ $$+";
       }
   }

   @Override
   public String toString() {
       return super.toString() + " Price: " + this.getCostSymbols()+" Rating: "+this.ratingToStars();
   }
  
  
}

PlaceDriver.java

public class PlaceDriver {
   public static void main(String[] args) {
       Attraction atr1 = new Attraction("Seaport Village", "Nice Place to see", 32.70872, -117.171, 55, 0);
       Attraction atr2 = new Attraction("San Diego Zoo", "Nice Place to see", 32.73607, -117.14927, 55, 2);
      
       Eatery eats = new Eatery("The Cottage", "nice place to eat", 32.84341, -117.275, "Chinese", 74, 4);
      
       System.out.println(atr1);
       System.out.println(atr2);
       System.out.println(eats);
   }
}

Sample Run:-

Seaport Village (latitude:32.70872,longitude:-117.171)
   Tickets average $55.0
San Diego Zoo (latitude:32.73607,longitude:-117.14927)
   Tickets average $55.0 and feature exciting animals
The Cottage (latitude:32.84341,longitude:-117.275)
   Price: $$$
   Rating: ****