Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.13 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStreamReader;
  3. import java.security.PrivilegedAction;
  4. import java.util.ArrayList;
  5. import java.util.Random;
  6. import java.util.Scanner;
  7. import java.util.concurrent.SynchronousQueue;
  8.  
  9. import javax.swing.text.StyledEditorKit.ForegroundAction;
  10.  
  11. import Oseba.Comparable;
  12. import Oseba.Test;
  13.  
  14. public class Izziv5{
  15.  
  16.    
  17.     public static void main(String[] args) {
  18.         // TODO Auto-generated method stub
  19.        
  20.         Scanner scanner = new Scanner(System.in);
  21.         System.out.println("How many people should we have?");
  22.         int n = scanner.nextInt();
  23.         //System.out.println(n);
  24.         String[] tt = new String[n];
  25.         System.out.println("Which attribute you wan't to edit 1 for name, 2 for surname, 3 for birth date");
  26.         int variable = scanner.nextInt();
  27.         System.out.println(variable);
  28.    
  29.        
  30.         //String test =  newPerson.ime.toString();
  31.         //System.out.println(newPerson.priimek);
  32.         //System.out.println(newPerson.ime);
  33.         for (int i = 0; i < n; i++) {
  34.             Oseba newPerson = new Oseba();
  35.             tt[i] = newPerson.ime + " " + newPerson.priimek + " "  + newPerson.letoR;
  36.             int lenghtName = newPerson.ime.length();
  37.             int lengthSurname = newPerson.priimek.length();
  38.             int birtda = newPerson.letoR;
  39.             String surname = tt[i].substring(lenghtName +1, lenghtName + lengthSurname + 2);
  40.             //String surname2 = tt[i].substring(lenghtName +1, lenghtName + lengthSurname + 2);
  41.             String birthDate = tt[i].substring(lengthSurname + lenghtName + 2, tt[i].length());
  42.             String date = birthDate;
  43.             //int date2 = Integer.parseInt(date);
  44.             String name = tt[i].substring(0, lenghtName);
  45.             //System.out.println(name);
  46.             //System.out.println(surname);
  47.             //System.out.println(birthDate);
  48.             System.out.println(tt[i]);
  49.             //System.out.println(tt[i]);
  50.            
  51.             }
  52.        
  53.         int i22 = tt[1].compareTo(tt[0]);
  54.         System.out.println(i22);
  55.  
  56.        
  57.        
  58.         /*String osebaIme = tt[1].substring(0, 4);
  59.         System.out.println(osebaIme);*/
  60.        
  61.        
  62.         for (int i = 1; i < tt.length; i++) {
  63.             /*if(tt[i-1].compareTo(tt[i]) < 1 ){
  64.                 String temp = tt[i];
  65.                 tt[i] = tt[i-1];
  66.                 tt[i-1] = temp;
  67.             }*/
  68.         }
  69.         /*for (int i = 0; i < tt.length; i++) {
  70.             System.out.println(tt[i]);
  71.         }
  72.         */
  73.        
  74.        
  75.         scanner.close();
  76.     }
  77.    
  78. }
  79.  
  80. class Oseba{
  81.    
  82.     Random rnd;
  83.     String priimek;
  84.     String ime;
  85.     int letoR;
  86.    
  87.     public  Oseba(){
  88.         String[] priimki = {"Zajc", "Krt", "Špes", "Malus", "Golob", "Hrastel", "Blatnik"};
  89.         String[] imena = {"Jure", "Lea", "Teja", "Tadej", "Jakob", "Anže", "Leon"};
  90.         rnd = new Random();
  91.  
  92.         priimek = priimki[rnd.nextInt(priimki.length)];
  93.         ime = imena[rnd.nextInt(imena.length)];
  94.         letoR = rnd.nextInt(2018 - 1900) + 1900;        
  95.     }
  96.  
  97.    
  98.  
  99.    
  100.     public interface Comparable{
  101.         public int compareTo(Object o);
  102.     }
  103.    
  104.     public Oseba(int args){
  105.         int attribute = 0;
  106.         Scanner scanner = new Scanner(System.in);
  107.         System.out.println("By what attribute you wan't to edit? 1 for name, 2 for surname, 3 for year of birth.");
  108.         attribute = scanner.nextInt();
  109.         int direction = 0;
  110.         System.out.println("In which direction you wanna edit array? 1 for normal, 2 for reverse");
  111.         direction = scanner.nextInt();
  112.         scanner.close();
  113.         Oseba newPerson = new Oseba();
  114.         String  ime = newPerson.ime;
  115.         Oseba newPers = new Oseba();
  116.         String ime2 = newPers.ime;
  117.         Oseba newPerson2 = new Oseba();
  118.         int  leto = newPerson2.letoR2;
  119.         Oseba newPers2 = new Oseba();
  120.         int leto2 = newPers2.letoR2;
  121.         Oseba newPerson3 = new Oseba();
  122.         String  priimek = newPerson3.priimek;
  123.         Oseba newPers3 = new Oseba();
  124.         String priimek2 = newPers3.priimek;
  125.         if(attribute == 3){
  126.             if(leto < leto2){
  127.                 int temp = leto2;
  128.                 leto2 = leto;
  129.                 leto = temp;       
  130.             }
  131.         }
  132.         else if(attribute == 1){   
  133.             if ( ime.compareTo(ime2) < 0) {
  134.                 String temp = ime2;
  135.                 ime2 = ime;
  136.                 ime = temp;
  137.             }
  138.         }
  139.         else if (attribute == 2){  
  140.             if (priimek.compareTo(priimek2) < 0){
  141.                 String temp = priimek2;
  142.                 priimek2 = priimek;
  143.                 priimek = temp;
  144.             }
  145.            
  146.         }
  147.     }
  148.    
  149.    
  150.    
  151.     public int compare(Oseba o){
  152.    
  153.         return this.ime.compareTo(o.ime);
  154.        
  155.     }
  156.    
  157.    
  158.     public void bubblesort(Comparable[] a){
  159.        
  160.     }
  161.    
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement