Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Point_actions
- {
- static Scanner scan = new Scanner(System.in);
- //משימה 4
- //addLast
- //איבר כללי ורשימה כללית ???
- //מה זה איך מתעסקים עם זה ואיזה פעולות יש לזה
- // ברשימה בשאלות להגשה אם היא מתכוונת לNODE או שהיא מתכוונת לLIST
- //public static void addLast()
- // משימה 3
- public static Point minX(Node<Point> first)
- {
- Node<Point>tmp = first;
- Point p = first.getValue();
- double X =tmp.getValue().getxPos();
- while(tmp != null)
- {
- if(tmp.getValue().getxPos() < X)
- {
- X = tmp.getValue().getxPos();
- p = tmp.getValue();
- }
- tmp=tmp.getNext();
- }
- return p;
- }
- // משימה 2
- public static int countPos(Node<Point> first)
- {
- int count =0;
- Node<Point>tmp = first;
- while(tmp != null)
- {
- if(tmp.getValue().getxPos() > 0 && tmp.getValue().getyPos() > 0){
- count++;
- }
- tmp=tmp.getNext();
- }
- return count;
- }
- // משימה 1
- public static Node<Point> createPointList()
- {
- System.out.println("Enter the amount of Points in the List");
- int length =scan.nextInt();
- System.out.println("Enter the p's X : ");
- double X = scan.nextInt();
- System.out.println("Enter the p's Y : ");
- double Y = scan.nextInt();
- Point p =new Point(X,Y);
- Node<Point> first =new Node<Point>(p);
- Node<Point>tmp =first;
- for(int i=1; i<length; i++)
- {
- System.out.println("Enter the p's X : ");
- X = scan.nextInt();
- System.out.println("Enter the p's Y : ");
- Y = scan.nextInt();
- Point P =new Point(X,Y);
- Node<Point> S =new Node<Point>(P);
- tmp.setNext(S);
- tmp = S;
- }
- return first;
- }
- //פעולה המדפיסה את הרשימה
- public static void print(Node node)
- {
- while(node !=null)
- {
- System.out.println(node);
- node = node.getNext();
- }
- }
- public static void main(String[]args)
- {
- //print(createPointList());
- //System.out.println(countPos(createPointList()));
- System.out.println(minX(createPointList()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment