Week 11 Discussion

 

1. What is an interface?

An interface is a partial template of what must be in a class that implements the interface. (Cahoon and Davidson, 491). To me this means that if we represent, lets say furniture. The interfaces of furniture would be different types (chairs, tables, lamps, rugs, etc. Each of those items may have similar qualities which we can include in a separate interface (wood, plastic, etc.). Further interfaces can be used to further break down similar and dissimilar qualities about furniture.

 

2. Two sub-questions of textbook problem 9.19.

(a)

public interface Ownership {

     public void setOwnerType();

     public String getOwnerType(String type);

     public void setVehicleUse();

     public int getVehicleUse(int use);

}

 

public interface Commercial extends Ownership {

     public void setCompanyName();

     public String getCompanyName(String s);

}

 

public Individual extends Ownership {

     public void setFamilyName();

     public String getFamilyName();

}

 

public Governmental extends Ownership {

     public void setAgency();

     public String getAgency(string s);

}

 

(b)

public interface Movement {

     public void setNumPassengers();

     public int getNumPassengers(int passengers);

     public void setTerrain();

     public String getTerrain(String t);

}

 

public interface Wheeled extends Movement {

     public void setNumWheels();

     public int getNumWheels(int wheels);

     public void setNumAxels();

     public int getNumAxels(int axels);

     public void setWheelSize();

     public double getWheelSize (int innerSize, double outtersize);

}

 

public interface NonWheeled extends Movement {

     public void setHowMoves();

     public String getHowMoves(String m);

}

 

3. Discuss the difference between an interface and a class.

A class does not allow for hierarchical  processing of more than one superclass, where as an interface allows for programs to access more than one interface.  To me, I visualize a class as two dimensional where as interfaces are multi-dimensional.  By using interfaces programmers are more easily able to compartmentalize their programs and make great use of OOP. 

 

Send me email

Visit my website

 


 

Home | Photos | WaterMark Multimedia | Online Shopping Outlet

Matt's Bio | UMUC | Feedback | Guest book | E-mail me

 

FaulknerWeb.com is designed and managed by Matt Faulkner.

Domain Name service provided by Namesecure

Web Service by eDataRack
Copyright © 1998 - 2011 [FaulknerWeb.com]. All rights reserved.
Updated: October 15, 2011 21:53 .