Advertisement
techno-

TVRealityList

Nov 1st, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package e2;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Iterator;
  5. import java.util.List;
  6. import java.util.concurrent.ThreadLocalRandom;
  7.  
  8. public abstract class TVRealityList implements Iterable<String>{
  9.     private int pos;
  10.     private List<String> lista = new ArrayList<String>();
  11.     private int k= getRandomValue(lista.size());
  12.  
  13.  
  14.     public abstract boolean hasNext();
  15.     public abstract Object next();
  16.     public abstract void remove();
  17.  
  18.     public static int getRandomValue(int size) {
  19.  
  20.         // Get and return the random integer
  21.         // within Min and Max
  22.         return ThreadLocalRandom
  23.                 .current()
  24.                 .nextInt(1, size + 1);
  25.     }
  26.  
  27.     public TVRealityList(int pos, ArrayList<String> lista, int k) {
  28.         this.pos = pos;
  29.         this.lista = lista;
  30.         this.k = k;
  31.     }
  32.  
  33.  
  34.     public int getPos() {
  35.         return pos;
  36.     }
  37.  
  38.     public void setPos(int pos) {
  39.         this.pos = pos;
  40.     }
  41.  
  42.     public ArrayList<String> getLista() {
  43.         return lista;
  44.     }
  45.  
  46.     public void setLista(ArrayList<String> lista) {
  47.         this.lista = lista;
  48.     }
  49.  
  50.     public int getK() {
  51.         return k;
  52.     }
  53.  
  54.     public void setK(int k) {
  55.         this.k = k;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement