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

Shape Circle Rectangle Square Figure 1. Part 1: Implement the classes in Figure

ID: 3683521 • Letter: S

Question

Shape Circle Rectangle Square Figure 1. Part 1: Implement the classes in Figure 1. 1. Abstract class Shape has a string name and two abstract methods area) and perimeter); 2. A concrete class Circle that extends Shape with a data member radius, and non abstract methods areaO, perimet 3. A concrete class Rectangle that extends Shape with a data member length and erO and tostringO. width, and non abstract methods areaO), perimeterO and toString O 4. A concrete class Square that extends Rectangle. A square is a special case of Rectangle with the two sides equal. Square.java public class square extends Rectanglet public Square (double length) super(length, length); 5. Write the TestShapes.java: create an ArrayList of of type Shape and assign differentshapes toit Callfunctions area(),perimeter()and --- -

Explanation / Answer


Eccentric.java:

package org.neo4j.graphalgo.impl.centrality;

import java.util.Comparator;
import java.util.Set;

import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath;
import org.neo4j.graphdb.Node;
public class Eccentricity<ShortestPathCostType> extends
ShortestPathBasedCentrality<ShortestPathCostType,ShortestPathCostType>
{
Comparator<ShortestPathCostType> distanceComparator;


public Eccentricity(
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
ShortestPathCostType zeroValue, Set<Node> nodeSet,
Comparator<ShortestPathCostType> distanceComparator )
{
super( singleSourceShortestPath, null, zeroValue, nodeSet );
this.distanceComparator = distanceComparator;
}

  
@Override
public ShortestPathCostType getCentrality( Node node )
{
ShortestPathCostType centrality = centralities.get( node );
if ( centrality == null )
{
return null;
}
  
if ( centrality.equals( zeroValue ) )
{
singleSourceShortestPath.reset();
singleSourceShortestPath.setStartNode( node );
processShortestPaths( node, singleSourceShortestPath );
}
// When the value is calculated, just retrieve it normally
return centralities.get( node );
}

@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
ShortestPathCostType maximumDistance = null;
for ( Node targetNode : nodeSet )
{
ShortestPathCostType targetDistance = singleSourceShortestPath
.getCost( targetNode );
if ( maximumDistance == null
|| distanceComparator.compare( maximumDistance, targetDistance ) < 0 )
{
maximumDistance = targetDistance;
}
}
if ( maximumDistance != null )
{
setCentralityForNode( node, maximumDistance );
}
}
}


TestShapes.java:


import java.util.Random;

public class TestShapes {
   public static Shape[] createShape() {
       final int SIZE = 5;
       final double DIMENSION = 100;
       final int NUMBEROFSHAPES = 3;

       Random generator = new Random();

       //create an array having b/w 1 and SIZE entries
       Shape[] randomShapes = new Shape[generator.nextInt(SIZE) + 1];

       for(int i = 0; i < randomShapes.length; i++)
       {
           //randomly generate values b/w 0 and NUMBEROFSHAPES - 1
           int assigner = generator.nextInt(NUMBEROFSHAPES);

           switch(assigner) {

               case 0: randomShapes[i] =
                   new Rectangle(generator.nextDouble()*DIMENSION,
                       generator.nextDouble()*DIMENSION);
                   break;

               case 1: randomShapes[i] =
                   new Circle(generator.nextDouble()*DIMENSION);
                   break;
               case 2: randomShapes[i] =
                   new Square(generator.nextDouble()*DIMENSION);
                   break;
               }
               }
               return randomShapes;
           }
      
           public static void main(String[] args) {
               Shape[] randomShapes = TestShapes.createShape();
               for(int i = 0; i < randomShapes.length; i++)
                   System.out.println(randomShapes[i]);
           }


Square.java:

public class Square extends Rectangle{
   public Square(double length){
       super(length, length);
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote