java - outputing lambda expression -
i'm having trouble in outputting result because of parameter map in interface iarea
public class lambda { public static void main(string[] args) { double x=10,y=8,pi=3.14159265359,radius=7; iarea triangle = (map<shapeproperties, double> props) -> { props.put(shapeproperties.base, x); props.put(shapeproperties.height, y); return (props.get(shapeproperties.base) * props.get(shapeproperties.height) / 2); }; iarea rectangle = (map<shapeproperties, double> props) -> { props.put(shapeproperties.width, x); props.put(shapeproperties.length, y); return (props.get(shapeproperties.base) * props.get(shapeproperties.height)); }; iarea circle = (map<shapeproperties, double> props) -> { props.put(shapeproperties.radius, radius); return (pi*math.pow(props.get(shapeproperties.radius),2)); }; //this part error occurs. system.out.println(triangle.getarea(map<shapeproperties, double> props)); } } could please guide me on how should approach outputting part of exercise? in advance.
here solution:
system.out.println(triangle.getarea(new hashmap<>())); the point need of pass map object triangle.getarea()
Comments
Post a Comment