Question

Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket pricFor each of the classes, you must have at least three constructors, a default constructor, a parametrized constructor (whichPart II For the requirements of this part, you need to modify your implementation from Part I as follows 1. The classes fromcode in java please:)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU

ANSWER:

JAVA CODE:

Here is code

PublicTransport.java

package transport.base;

public class PublicTransportation {
   protected double ticketPrice;
   protected int numStops;
   public PublicTransportation()
   {
      
   }
  
   public PublicTransportation(double tktprice, int noStops)
   {
       ticketPrice = tktprice;
       numStops = noStops;
   }
  
   public PublicTransportation(PublicTransportation other)
   {
       this.ticketPrice = other.ticketPrice;
       this.numStops = other.numStops;
   }
  
   public double getTicketPrice() {
       return ticketPrice;
   }
   public void setTicketPrice(double ticketPrice) {
       this.ticketPrice = ticketPrice;
   }
   public int getNumStops() {
       return numStops;
   }
   public void setNumStops(int numStops) {
       this.numStops = numStops;
   }
   @Override
   public boolean equals(Object obj) {
       if(obj == null)
           return false;
       if(obj instanceof PublicTransportation)
       {
           PublicTransportation pt = (PublicTransportation)obj;
           return (ticketPrice == pt.ticketPrice && numStops == pt.numStops);
       }
       else
           return false;
   }
   @Override
   public String toString() {
       return "This PublicTransport has " + numStops + " stops, and costs $" + String.format("%.2f", ticketPrice) +"."+"\n";
   }
  
}

CityBus.java

package transport.type1;

import transport.base.PublicTransportation;

public class CityBus extends PublicTransportation {
   protected long routeNo;
   protected int beginYear;
   protected String lineName;
   protected String driverName;
  
   public CityBus(){
       super();
   }
  
   public CityBus(double tktPrice, int stops, long route, int year, String line, String driver){
       super(tktPrice, stops);
       routeNo = route;
       beginYear = year;
       lineName = line;
       driverName = driver;
   }
  
   public CityBus(CityBus other)
   {
       super(other);
       routeNo = other.routeNo;
       beginYear = other.beginYear;
       lineName = other.lineName;
       driverName = other.driverName;
   }
  
  
   public long getRouteNo() {
       return routeNo;
   }
   public void setRouteNo(long routeNo) {
       this.routeNo = routeNo;
   }
   public int getBeginYear() {
       return beginYear;
   }
   public void setBeginYear(int beginYear) {
       this.beginYear = beginYear;
   }
   public String getLineName() {
       return lineName;
   }
   public void setLineName(String lineName) {
       this.lineName = lineName;
   }
   public String getDriverName() {
       return driverName;
   }
   public void setDriverName(String driverName) {
       this.driverName = driverName;
   }

   @Override
   public boolean equals(Object obj) {
       if(super.equals(obj) && obj instanceof CityBus)
       {
           CityBus cb = (CityBus)obj;
           return (routeNo == cb.routeNo && lineName.equals(cb.lineName) &&
                   beginYear == cb.beginYear && driverName.equals(cb.driverName));
       }
       else
           return false;
   }

   @Override
   public String toString() {
       String str = super.toString().replace("PublicTransport", "CityBus") ;
       str += "It was started in " + beginYear + " and its route no. is " + routeNo + " and ";
       str += "line is " + lineName +". It's driven by " + driverName +"." +"\n";
       return str;
   }
  
  

}

Tram.java

package transport.type1;

public class Tram extends CityBus {
   protected int maxSpeed;
  
   public Tram()
   {
       super();
   }
  
   public Tram(double tktPrice, int stops, long route, int year, String line, String driver, int maxSpd)
   {
       super(tktPrice, stops, route, year, line, driver);
       this.maxSpeed = maxSpd;
   }
  
   public Tram(Tram other)
   {
       super(other);
       this.maxSpeed = other.maxSpeed;
   }

   public int getMaxSpeed() {
       return maxSpeed;
   }

   public void setMaxSpeed(int maxSpeed) {
       this.maxSpeed = maxSpeed;
   }

   @Override
   public boolean equals(Object obj) {
       if(super.equals(obj) && obj instanceof Tram)
           return maxSpeed == ((Tram)obj).maxSpeed;
       else
           return false;
   }

   @Override
   public String toString() {
         
       String str = super.toString().replace("CityBus", "Tram");
       str += "It's maximum speed is " + maxSpeed + " km/h" +"\n";
       return str;
   }
  
  
}

Metro.java

package transport.type1;

public class Metro extends CityBus {
   protected int noOfVehicles;
   protected String city;
  
   public Metro()
   {
       super();
   }
  
   public Metro(double tktPrice, int stops, long route, int year, String line, String driver, int vehicles, String cty)
   {
       super(tktPrice, stops, route, year, line, driver);
       this.noOfVehicles = vehicles;
       this.city = cty;
   }
  
   public Metro(Metro other)
   {
       super(other);
       this.noOfVehicles = other.noOfVehicles;
       this.city = other.city;
   }

   public int getNoOfVehicles() {
       return noOfVehicles;
   }

   public void setNoOfVehicles(int noOfVehicles) {
       this.noOfVehicles = noOfVehicles;
   }

   public String getCity() {
       return city;
   }

   public void setCity(String city) {
       this.city = city;
   }

   @Override
   public boolean equals(Object obj) {
       if(super.equals(obj) && obj instanceof Metro)
       {
           Metro m = (Metro) obj;
           return noOfVehicles == m.noOfVehicles && city.equals(m.city);
       }
       else
           return false;
   }

   @Override
   public String toString() {
       String str = super.toString().replace("CityBus", "Metro") ;
       str += "It has " + noOfVehicles + " vehicles and travels to " + city +"\n";
       return str;
   }
  
  
}

Ferry.java

package transport.type2;

import transport.base.PublicTransportation;

public class Ferry extends PublicTransportation {
   protected int buildYear;
   protected String shipName;
  
   public Ferry()
   {
       super();
   }
   public Ferry(double tktprice, int noStops, int year, String name)
   {
       super(tktprice, noStops);
       this.buildYear = year;
       this.shipName = name;
   }
  
   public Ferry(Ferry other)
   {
       super(other);
       this.buildYear = other.buildYear;
       this.shipName = other.shipName;
   }
   public int getBuildYear() {
       return buildYear;
   }
   public void setBuildYear(int buildYear) {
       this.buildYear = buildYear;
   }
   public String getShipName() {
       return shipName;
   }
   public void setShipName(String shipName) {
       this.shipName = shipName;
   }
   @Override
   public boolean equals(Object obj) {
       if(super.equals(obj) && obj instanceof Ferry)
       {
           Ferry f = (Ferry)obj;
           return buildYear == f.buildYear && shipName.equals(f.shipName);
       }
       else
           return false;
   }
   @Override
   public String toString() {
       String str = super.toString().replace("PublicTransport", "Ferry");
       str += "It is named " + shipName + " and was built in " + buildYear +"\n";
       return str;
   }
  
  
}

AirCraft.java

package transport.type2;

import transport.base.PublicTransportation;

public class AirCraft extends PublicTransportation {
   public enum ClassType {Helicopter, Airline, Glider, Balloon};
   public enum MaintenanceType {Weekly, Monthly, Yearly};
  
   protected ClassType classType;
   protected MaintenanceType maintenanceType;
  
   public AirCraft()
   {
       super();
      
   }
  
   public AirCraft(double tktprice, int noStops, ClassType ctype, MaintenanceType mType)
   {
       super(tktprice, noStops);
       this.classType = ctype;
       this.maintenanceType = mType;
   }
  
   public AirCraft(AirCraft other)
   {
       super(other);
       this.classType = other.classType;
       this.maintenanceType = other.maintenanceType;
   }

   public ClassType getClassType() {
       return classType;
   }

   public void setClassType(ClassType classType) {
       this.classType = classType;
   }

   public MaintenanceType getMaintenanceType() {
       return maintenanceType;
   }

   public void setMaintenanceType(MaintenanceType maintenanceType) {
       this.maintenanceType = maintenanceType;
   }

   @Override
   public boolean equals(Object obj) {
       if(super.equals(obj) && obj instanceof AirCraft)
       {
           AirCraft ac = (AirCraft)obj;
           return classType == ac.classType && maintenanceType == ac.maintenanceType;
       }
       else
           return false;
   }

   @Override
   public String toString() {
       String ac = "";
       switch(classType)
       {
           case Helicopter:
               ac = "Helicopter";
               break;
           case Airline:
               ac = "Airline";
               break;
           case Glider:
               ac = "Glider";
               break;
           case Balloon:
               ac = "Balloon";
               break;
       }
      
       String str = super.toString().replace("PublicTransport", ac) ;
       str += "It needs ";
      
       switch(maintenanceType)
       {
           case Weekly:
               str += "Weekly ";
               break;
           case Monthly:
               str += "Monthly ";
               break;
           case Yearly:
               str += "Yearly ";
               break;
              
       }
       str += " maintenance." +"\n";
      
       return str;
   }
  
  
  
}

TransportDriverPart1.java

package transport;

import transport.base.PublicTransportation;
import transport.type1.CityBus;
import transport.type1.Metro;
import transport.type1.Tram;
import transport.type2.AirCraft;
import transport.type2.Ferry;
import transport.type2.AirCraft.ClassType;
import transport.type2.AirCraft.MaintenanceType;

public class TransportDriverPart1 {
  
   private static void printLowest(PublicTransportation trans[])
   {
       int minIdx = 0;
       for(int i = 1; i < trans.length; i++)
           if(trans[i].getTicketPrice() < trans[minIdx].getTicketPrice())
               minIdx = i;
      
       System.out.println("\nThe lowest ticket price is at index " + minIdx + " for \n" + trans[minIdx]);
   }
  
   private static void printHighest(PublicTransportation trans[])
   {
       int maxIdx = 0;
       for(int i = 1; i < trans.length; i++)
           if(trans[i].getTicketPrice() > trans[maxIdx].getTicketPrice())
               maxIdx = i;
      
       System.out.println("\nThe highest ticket price is at index " + maxIdx + " for \n" + trans[maxIdx]);
   }
   public static void main(String[] args) {
       PublicTransportation publicTrans = new PublicTransportation(5, 8);
       CityBus bus = new CityBus(5, 5, 111, 2000, "citybus line1", "john");
       Tram tram = new Tram(7, 8, 222, 2001, "tram line1" , "bob", 70);
       Metro metro = new Metro(10, 10, 333, 2002, "metros line1" , "peter", 4, "Toronto");
       Ferry ferry = new Ferry(50, 5, 2004, "Ship1");
       AirCraft aircraft = new AirCraft(100, 2, ClassType.Helicopter, MaintenanceType.Weekly);
      
       System.out.println(publicTrans);
       System.out.println(bus);
       System.out.println(tram);
       System.out.println(metro);
       System.out.println(ferry);
       System.out.println(aircraft);
      
       CityBus bus2 = new CityBus(5, 5, 111, 2000, "citybus line1", "john");
       if(bus.equals(bus2))
           System.out.println("the 2 city bus are equal");
       else
           System.out.println("the 2 city bus are not equal");
      
      
       PublicTransportation[] transArr = new PublicTransportation[10];
       transArr[0] = bus;
       transArr[1] = tram;
       transArr[2] = metro;
       transArr[3] = ferry;
       transArr[4] = aircraft;
       transArr[5] = new CityBus(6, 5, 666, 2000, "line2", "michael");
       transArr[6] = new Tram(9, 8, 777, 2001, "tram line1" , "bob", 70);
       transArr[7] = new CityBus(4, 5, 888, 2000, "line2", "michael");
       transArr[8] = new CityBus(2, 5, 999, 2000, "line2", "michael");
       transArr[9] = new CityBus(2, 5, 1010, 2000, "line2", "michael");
      
       printLowest(transArr);
      
       printHighest(transArr);
      
      
   }
}

output

This PublicTransport has 8 stops, and costs $5.00.

This CityBus has 5 stops, and costs $5.00.
It was started in 2000 and its route no. is 111 and line is citybus line1. It's driven by john.

This Tram has 8 stops, and costs $7.00.
It was started in 2001 and its route no. is 222 and line is tram line1. It's driven by bob.
It's maximum speed is 70 km/h

This Metro has 10 stops, and costs $10.00.
It was started in 2002 and its route no. is 333 and line is metros line1. It's driven by peter.
It has 4 vehicles and travels to Toronto

This Ferry has 5 stops, and costs $50.00.
It is named Ship1 and was built in 2004

This Helicopter has 2 stops, and costs $100.00.
It needs Weekly maintenance.

the 2 city bus are equal

The lowest ticket price is at index 8 for
This CityBus has 5 stops, and costs $2.00.
It was started in 2000 and its route no. is 999 and line is line2. It's driven by michael.


The highest ticket price is at index 4 for
This Helicopter has 2 stops, and costs $100.00.
It needs Weekly maintenance.

TransportDriverPart2.java

package transport;

import transport.base.PublicTransportation;
import transport.type1.CityBus;
import transport.type1.Metro;
import transport.type1.Tram;
import transport.type2.AirCraft;
import transport.type2.Ferry;
import transport.type2.AirCraft.ClassType;
import transport.type2.AirCraft.MaintenanceType;

public class TransportDriverPart2 {
  
   private static void printLowest(PublicTransportation[] trans)
   {
       int minIdx = 0;
       for(int i = 1; i < trans.length; i++)
           if(trans[i].getTicketPrice() < trans[minIdx].getTicketPrice())
               minIdx = i;
      
       System.out.println("\nThe lowest ticket price is at index " + minIdx + " for \n" + trans[minIdx]);
   }
  
   private static void printHighest(PublicTransportation[] trans)
   {
       int maxIdx = 0;
       for(int i = 1; i < trans.length; i++)
           if(trans[i].getTicketPrice() > trans[maxIdx].getTicketPrice())
               maxIdx = i;
      
       System.out.println("\nThe highest ticket price is at index " + maxIdx + " for \n" + trans[maxIdx]);
   }
  
   private static PublicTransportation[] copyAll(PublicTransportation[] trans)
   {
       PublicTransportation[] copy = new PublicTransportation[trans.length];
       for(int i = 0; i < trans.length; i++)
       {
          
           if(trans[i] instanceof Tram)
               copy[i] = new Tram((Tram)trans[i]);
           else if(trans[i] instanceof Metro)
               copy[i] = new Metro((Metro)trans[i]);
           else if(trans[i] instanceof Ferry)
               copy[i] = new Ferry((Ferry)trans[i]);
           else if(trans[i] instanceof AirCraft)
               copy[i] = new AirCraft((AirCraft)trans[i]);
           else if(trans[i] instanceof CityBus)
               copy[i] = new CityBus((CityBus)trans[i]);
           else if(trans[i] instanceof PublicTransportation)
               copy[i] = new PublicTransportation(trans[i]);
          
      
          
       }
       return copy;
   }
  
   private static void print(PublicTransportation[] trans)
   {
       for(int i = 0; i < trans.length; i++)
           System.out.println(trans[i].toString());
   }
   public static void main(String[] args) {
       PublicTransportation publicTrans = new PublicTransportation(5, 8);
       CityBus bus = new CityBus(5, 5, 111, 2000, "citybus line1", "john");
       Tram tram = new Tram(7, 8, 222, 2001, "tram line1" , "bob", 70);
       Metro metro = new Metro(10, 10, 333, 2002, "metros line1" , "peter", 4, "Toronto");
       Ferry ferry = new Ferry(50, 5, 2004, "Ship1");
       AirCraft aircraft = new AirCraft(100, 2, ClassType.Helicopter, MaintenanceType.Weekly);
      
       System.out.println(publicTrans);
       System.out.println(bus);
       System.out.println(tram);
       System.out.println(metro);
       System.out.println(ferry);
       System.out.println(aircraft);
      
       CityBus bus2 = new CityBus(5, 5, 111, 2000, "citybus line1", "john");
       if(bus.equals(bus2))
           System.out.println("the 2 city bus are equal");
       else
           System.out.println("the 2 city bus are not equal");
      
      
       PublicTransportation[] transArr = new PublicTransportation[10];
       transArr[0] = bus;
       transArr[1] = tram;
       transArr[2] = metro;
       transArr[3] = ferry;
       transArr[4] = aircraft;
       transArr[5] = new CityBus(6, 5, 666, 2000, "line2", "michael");
       transArr[6] = new Tram(9, 8, 777, 2001, "tram line1" , "bob", 70);
       transArr[7] = new CityBus(4, 5, 888, 2000, "line2", "michael");
       transArr[8] = new CityBus(2, 5, 999, 2000, "line2", "michael");
       transArr[9] = new CityBus(2, 5, 1010, 2000, "line2", "michael");
      
       System.out.println("The array of transports contains ");
       print(transArr);
       System.out.println("=====================================");
       printLowest(transArr);
      
       printHighest(transArr);
       System.out.println("=====================================");
       System.out.println("Copying the transport array using copy constructor...");
       PublicTransportation[] copied = copyAll(transArr);
       System.out.println("The copied array is");
       print(copied);
      
      
   }
}

outptu

This PublicTransport has 8 stops, and costs $5.00.

This CityBus has 5 stops, and costs $5.00.

It was started in 2000 and its route no. is 111 and line is citybus line1. It's driven by john.

This Tram has 8 stops, and costs $7.00.

It was started in 2001 and its route no. is 222 and line is tram line1. It's driven by bob.

It's maximum speed is 70 km/h

This Metro has 10 stops, and costs $10.00.

It was started in 2002 and its route no. is 333 and line is metros line1. It's driven by peter.

It has 4 vehicles and travels to Toronto

This Ferry has 5 stops, and costs $50.00.

It is named Ship1 and was built in 2004

This Helicopter has 2 stops, and costs $100.00.

It needs Weekly maintenance.

the 2 city bus are equal

The array of transports contains

This CityBus has 5 stops, and costs $5.00.

It was started in 2000 and its route no. is 111 and line is citybus line1. It's driven by john.

This Tram has 8 stops, and costs $7.00.

It was started in 2001 and its route no. is 222 and line is tram line1. It's driven by bob.

It's maximum speed is 70 km/h

This Metro has 10 stops, and costs $10.00.

It was started in 2002 and its route no. is 333 and line is metros line1. It's driven by peter.

It has 4 vehicles and travels to Toronto

This Ferry has 5 stops, and costs $50.00.

It is named Ship1 and was built in 2004

This Helicopter has 2 stops, and costs $100.00.

It needs Weekly maintenance.

This CityBus has 5 stops, and costs $6.00.

It was started in 2000 and its route no. is 666 and line is line2. It's driven by michael.

This Tram has 8 stops, and costs $9.00.

It was started in 2001 and its route no. is 777 and line is tram line1. It's driven by bob.

It's maximum speed is 70 km/h

This CityBus has 5 stops, and costs $4.00.

It was started in 2000 and its route no. is 888 and line is line2. It's driven by michael.

This CityBus has 5 stops, and costs $2.00.

It was started in 2000 and its route no. is 999 and line is line2. It's driven by michael.

This CityBus has 5 stops, and costs $2.00.

It was started in 2000 and its route no. is 1010 and line is line2. It's driven by michael.

=====================================

The lowest ticket price is at index 8 for

This CityBus has 5 stops, and costs $2.00.

It was started in 2000 and its route no. is 999 and line is line2. It's driven by michael.

The highest ticket price is at index 4 for

This Helicopter has 2 stops, and costs $100.00.

It needs Weekly maintenance.

=====================================

Copying the transport array using copy constructor...

The copied array is

This CityBus has 5 stops, and costs $5.00.

It was started in 2000 and its route no. is 111 and line is citybus line1. It's driven by john.

This Tram has 8 stops, and costs $7.00.

It was started in 2001 and its route no. is 222 and line is tram line1. It's driven by bob.

It's maximum speed is 70 km/h

This Metro has 10 stops, and costs $10.00.

It was started in 2002 and its route no. is 333 and line is metros line1. It's driven by peter.

It has 4 vehicles and travels to Toronto

This Ferry has 5 stops, and costs $50.00.

It is named Ship1 and was built in 2004

This Helicopter has 2 stops, and costs $100.00.

It needs Weekly maintenance.

This CityBus has 5 stops, and costs $6.00.

It was started in 2000 and its route no. is 666 and line is line2. It's driven by michael.

This Tram has 8 stops, and costs $9.00.

It was started in 2001 and its route no. is 777 and line is tram line1. It's driven by bob.

It's maximum speed is 70 km/h

This CityBus has 5 stops, and costs $4.00.

It was started in 2000 and its route no. is 888 and line is line2. It's driven by michael.

This CityBus has 5 stops, and costs $2.00.

It was started in 2000 and its route no. is 999 and line is line2. It's driven by michael.

This CityBus has 5 stops, and costs $2.00.

It was started in 2000 and its route no. is 1010 and line is line2. It's driven by michael.

HOPE IT HELPS YOU

RATE THUMBSUP PLEASE

Add a comment
Know the answer?
Add Answer to:
code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write in java and please code the four classes with the requirements instructed You will be...

    write in java and please code the four classes with the requirements instructed You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four classes. The classes must include: 1. Employee Class with the attributes of Employee ID, First Name, Middle Initial, Last Name, Date of Employment. 2. Employee Type Class that has two instances of EmployeeType objects: salaried and hourly. Each object will have methods that calculates employees payrol...

  • 1- Write a code for a banking program. a) In this question, first, you need to...

    1- Write a code for a banking program. a) In this question, first, you need to create a Customer class, this class should have: • 2 private attributes: name (String) and balance (double) • Parametrized constructor to initialize the attributes • Methods: i. public String toString() that gives back the name and balance ii. public void addPercentage; this method will take a percentage value and add it to the balance b) Second, you will create a driver class and ask...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • Java Object Array With 2 Elements In 1 Object

    1. Create a UML diagram to help design the class described in Q2 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Person class object; should they be private or public? Determine what class methods are required; should they be private or public?2. Write Java code for a Person class. A Person has a name of type String and an age of type integer.Supply two constructors: one will be...

  • Create a UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? 3. Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two...

  • no buffered reader. no try catch statements. java code please. And using this super class: Medialtemjava...

    no buffered reader. no try catch statements. java code please. And using this super class: Medialtemjava a Create the "middle" of the diagram, the DVD and ForeignDVD classes as below: The DVD class will have the following attributes and behaviors: Attributes (in addition to those inherited from Medialtem): • director:String • rating: String • runtime: int (this will represent the number of minutes) Behaviors (methods) • constructors (at least 3): the default, the "overloaded" as we know it, passing in...

  • Here is a sample run of the tester program: Make sure your program follows the Java...

    Here is a sample run of the tester program: Make sure your program follows the Java Coding Guidelines. Consider the following class: /** * A store superclass with a Name and Sales Tax Rate */ public class Store {      public final double SALES_TAX_RATE = 0.06;      private String name;           /**      * Constructor to create a new store      * @param newName      */      public Store(String newName)      {           name = newName;      }     ...

  • You are given a specification for some Java classes as follows.   A building has a number...

    You are given a specification for some Java classes as follows.   A building has a number of floors, and a number of windows. A house is a building. A garage is a building. (This isn’t Florida-like … it’s a detached garage.) A room has a length, width, a floor covering, and a number of closets. You can never create an instance of a building, but every object that is a building must have a method that calculates the floor space,...

  • Please write in Java Language Write an abstract class Shape with an attribute for the name...

    Please write in Java Language Write an abstract class Shape with an attribute for the name of the shape (you'll use this later to identify a particular shape). Include a constructor to set the name of the shape and an abstract calculateArea method that has no parameters and returns the area of the shape. Optionally, include a constructor that returns the name of the shape and its area (by calling the calculateArea method). Write a Rectangle class that inherits from...

  • Hello, In need of help with this Java pa homework. Thank you! 2. Create a normal...

    Hello, In need of help with this Java pa homework. Thank you! 2. Create a normal (POJo, JavaBean) class to represent, i. e. model, varieties of green beans (also known as string beans or snap beans). Following the steps shown in "Assignment: Tutorial on Creating Classes in IntelliJ", create the class in a file of its own in the same package as class Main. Name the class an appropriate name. The class must have (a) private field variables of appropriate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT