Question

In: Computer Science

You will follow a contract-first approach using interfaces. Here are the main specifications of the contract...

You will follow a contract-first approach using interfaces. Here are the main specifications of the contract to build the graph application. There are four interfaces.

ILocation: defines a generic interface for any location object

  • It is an empty interface
  • It is Comparable

ILocation

ILocation2D: defines an interface for 2D locations

  • gets and sets its x and y coordinates
  • it extends the generic interface ILocation

ILocation2D

ILocation3D:

  • gets and sets its z coordinate.
  • It extends the interface ILocation2D

ILocation3D

ICity: defines an interface for City objects.

  • gets and sets
    • the name (String),
    • location (ILocation), and
  • It is Comparable.

ICity

IRoute: define a generic interface for a route.

  • it is Comparable and can be compared to another IRoute object.
  • gets the path as a List of ICity object
  • returns the length of path as a double
  • returns the location of the start location of the path as ILocation object
  • returns the location of the destination location of the path as ILocation object

IRoute

Solutions

Expert Solution

Here are all interfaces created as per specification:

1. ILocation:


package comaprableinterfaces;


public interface ILocation extends Comparable {
        //Empty interfave
}

2. ILocation2D:

package comaprableinterfaces;

//defines an interface for 2D locations
//it extends the generic interface ILocation
public interface ILocation2D extends ILocation {
        int x=0;
        int y=0;
        
        //gets and sets its x and y coordinates
        void setX(int x);
        void setY(int y);
        
        int getX();
        int getY();
}

3.ILocation3D:

package comaprableinterfaces;

//It extends the interface ILocation2D
public interface ILocation3D extends ILocation2D {
        
        int z=0;
        
        //gets and sets its z coordinate.
        void setZ(int z);
        int getZ();
}

4.ICity:

package comaprableinterfaces;

//defines an interface for City objects. and is comparable
public interface ICity extends Comparable<ICity> {

        String name=null;
        ILocation location=null;
        
        /*
         * gets and sets the name (String), location (ILocation)
         */
        void setName(String name);
        void SetLocation(ILocation location);
        
        String getName();
        ILocation getLocation();
}

5. IRoute:

package comaprableinterfaces;

import java.util.List;

//define a generic interface for a route
//it is Comparable and can be compared to another IRoute object.
public interface IRoute extends Comparable<IRoute> {

        //gets the path as a List of ICity object
        List<ICity> path=null;
        
        //returns the length of path as a double
        double lengthofPath();
        
        //returns the location of the start location of the path as ILocation object
        ILocation startLocationOfPath();
        
        //returns the location of the destination location of the path as ILocation object
        ILocation destinationLocationOfPath();
        
        
}

All Interface screenshots:


Related Solutions

what are the main steps to follow when you are projecting valuation of a company using...
what are the main steps to follow when you are projecting valuation of a company using Discounted Cash Flow Methods? What assumptions you may need to make in order to complete your valuation process for a start up company which data you may alreayd have in hand?
1. For this assignment you will need to first build a graph to these specifications: Draw...
1. For this assignment you will need to first build a graph to these specifications: Draw a downward sloping demand curve with vertical intercept (0,150) and horizontal intercept (25,0). Draw a supply curve with vertical intercept (0,50) and with slope=4 i.e. the market equilibrium occurs at (10, 90). a. Compute consumer, producer, and total surplus at the market equilibrium. b. Label consumer surplus and producer surplus if the government imposes a price floor of $120, then compute deadweight loss. c....
Using the provided code (found here), write a program using the main method where the user...
Using the provided code (found here), write a program using the main method where the user enters Strings and the program echoes these strings to the console until the user enters “quit”. When user quits the program should print out, “Goodbye”. You may assume that the case is ignored when the user enters, “quit”, so “quit”, “QUIT”, “Quit”,“qUiT”, etc. are all acceptable ways to end the program. The results should be printed out to the console in the following format:...
Confused about going through this C program. Thank you Program Specifications: *********************************************** ** MAIN MENU **...
Confused about going through this C program. Thank you Program Specifications: *********************************************** ** MAIN MENU ** *********************************************** A) Enter game results B) Current Record (# of wins and # of losses and # of ties) C) Display ALL results from all games WON D) Display ALL results ordered by opponent score from low to high. E) Quit Your program will have a menu similar to the example above. The game results will simply be the score by your team and...
Create an application to simulate a bank ATM and you must combine graphical interfaces using Swing...
Create an application to simulate a bank ATM and you must combine graphical interfaces using Swing or AWT and relational databases. We will have a Bank Accounts database. Each account will have an account number, the name of the owner and the account balance. The program must allow the following options: a) Create an account: request the account information and save it in the database. b) Enter the ATM: it will allow you to request the account number and will...
1. Magic Mountain accounts for revenues using the contract-based approach. It operates a ski resort. Ski...
1. Magic Mountain accounts for revenues using the contract-based approach. It operates a ski resort. Ski Season tickets are sold throughout the year, and entitle the holder to ski any day all season long. They are non-refundable. When should Magic Mountain recognize revenue for the season tickets? a. at the time of sale b. on the day the mountain first opens for skiing c. throughout the ski season d. at the end of the ski season 2. Frenzo Furniture Co....
USING JAVA (netbeans) In your main, ask the user for an int. Do this by first...
USING JAVA (netbeans) In your main, ask the user for an int. Do this by first printing a request for the int, then creating an int x, and using the Scanner to read an int from the user and put it in x, like this: int x = scan.nextInt(); ☑ Next read in two doubles d1 and d2 from the user. This will look a lot like what you did for the int, but the scanner reads doubles using scan.nextDouble();...
Naïve Approach- Using the naïve approach forecast the average domestic airfare for 2014. Explain how you...
Naïve Approach- Using the naïve approach forecast the average domestic airfare for 2014. Explain how you calculated this value. How accurate do you think this forecast is? Moving Averages: Using the 4-year moving average approach forecast the average airfare for 2014. Explain how you calculated this value. How accurate do you think this forecast is? Exponential Smoothing: Using the exponential smoothing approach with α = 0.40 forecast average airfare for 2014. Explain how you calculated this value. Round each forecast...
You are using the FCFF approach to value a business. You have estimated that the FCFF...
You are using the FCFF approach to value a business. You have estimated that the FCFF for next year will be $146.50 million and that it will increase at a rate of 10 percent for each of the following four years. After that point, the FCFF will increase at a rate of 4 percent forever. If the WACC for this firm is 13 percent and it has no NOA, what is it worth? (Round answer to 2 decimal places, e.g....
You are asked to define 10 different " The right hand rule". Here you first define...
You are asked to define 10 different " The right hand rule". Here you first define the application and explain how the right hand rule is applied to find the direction of physical concept.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT