use of hr.fer.oop.recap2.task2.DistanceFromOrigin in project Lectures by FER-OOP.
the class Main method main.
public static void main(String[] args) {
List<Point> list = new ArrayList<>();
list.add(new Point(-5, 12));
list.add(new Point(3, -4));
list.add(new Point(12, 9));
list.add(new Point(3, 4));
list.add(new Point(4, 3));
list.add(new Point(-9, 12));
list.add(new Point(-5, -12));
DistanceFromOrigin dist = new DistanceFromOrigin();
List<String> newlist = list.stream().filter(new QuadrantPredicate(true, true, false, true)).sorted(new PointComparator().reversed()).map(p -> String.format("dist(%s) = %.2f", p, dist.apply(p))).collect(Collectors.toList());
System.out.println(newlist);
}
use of hr.fer.oop.recap2.task2.DistanceFromOrigin in project Lectures by FER-OOP.
the class Main method main.
public static void main(String[] args) {
List<Point> list = new ArrayList<>();
list.add(new Point(-5, 12));
list.add(new Point(3, -4));
list.add(new Point(12, 9));
list.add(new Point(3, 4));
list.add(new Point(4, 3));
list.add(new Point(-9, 12));
list.add(new Point(-5, -12));
DistanceFromOrigin dist = new DistanceFromOrigin();
OptionalDouble avg = list.stream().filter(new QuadrantPredicate(true, false, false, false)).mapToDouble(p -> dist.apply(p)).average();
avg.ifPresentOrElse(val -> System.out.println("Avg = " + val), () -> System.out.println("No data for selected quadrants"));
}
Aggregations