Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Program
- {
- public static void main(String[] args) {
- System.out.println("Enter new set maximal size");
- Scanner s = new Scanner(System.in);
- int max = s.nextInt();
- Set se = new Set(max);
- int n = 1;
- while(n!=0)
- {
- System.out.print("Current set is: ");
- se.show();
- System.out.println("Press 0 to exit program.");
- System.out.println("Press 1 to add new number to set.");
- System.out.println("Press 2 to remove exisiting number from set.");
- n = s.nextInt();
- if(n == 0)
- break;
- else if(n == 1)
- {
- System.out.println("Enter a number to add to set");
- n = s.nextInt();
- if(se.add(n))
- System.out.println("Adding " + n + " succeeded");
- else
- System.out.println("Adding " + n + " failed");
- }
- else if(n == 2)
- {
- System.out.println("Enter a number to remove from set");
- n = s.nextInt();
- if(se.remove(n))
- System.out.println("Removing " + n + " succeeded");
- else
- System.out.println("Removing " + n + " failed");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement