Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.security.PrivilegedAction;
- import java.util.ArrayList;
- import java.util.Random;
- import java.util.Scanner;
- import java.util.concurrent.SynchronousQueue;
- import javax.swing.text.StyledEditorKit.ForegroundAction;
- import Oseba.Comparable;
- import Oseba.Test;
- public class Izziv5{
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scanner = new Scanner(System.in);
- System.out.println("How many people should we have?");
- int n = scanner.nextInt();
- //System.out.println(n);
- String[] tt = new String[n];
- System.out.println("Which attribute you wan't to edit 1 for name, 2 for surname, 3 for birth date");
- int variable = scanner.nextInt();
- System.out.println(variable);
- //String test = newPerson.ime.toString();
- //System.out.println(newPerson.priimek);
- //System.out.println(newPerson.ime);
- for (int i = 0; i < n; i++) {
- Oseba newPerson = new Oseba();
- tt[i] = newPerson.ime + " " + newPerson.priimek + " " + newPerson.letoR;
- int lenghtName = newPerson.ime.length();
- int lengthSurname = newPerson.priimek.length();
- int birtda = newPerson.letoR;
- String surname = tt[i].substring(lenghtName +1, lenghtName + lengthSurname + 2);
- //String surname2 = tt[i].substring(lenghtName +1, lenghtName + lengthSurname + 2);
- String birthDate = tt[i].substring(lengthSurname + lenghtName + 2, tt[i].length());
- String date = birthDate;
- //int date2 = Integer.parseInt(date);
- String name = tt[i].substring(0, lenghtName);
- //System.out.println(name);
- //System.out.println(surname);
- //System.out.println(birthDate);
- System.out.println(tt[i]);
- //System.out.println(tt[i]);
- }
- int i22 = tt[1].compareTo(tt[0]);
- System.out.println(i22);
- /*String osebaIme = tt[1].substring(0, 4);
- System.out.println(osebaIme);*/
- for (int i = 1; i < tt.length; i++) {
- /*if(tt[i-1].compareTo(tt[i]) < 1 ){
- String temp = tt[i];
- tt[i] = tt[i-1];
- tt[i-1] = temp;
- }*/
- }
- /*for (int i = 0; i < tt.length; i++) {
- System.out.println(tt[i]);
- }
- */
- scanner.close();
- }
- }
- class Oseba{
- Random rnd;
- String priimek;
- String ime;
- int letoR;
- public Oseba(){
- String[] priimki = {"Zajc", "Krt", "Špes", "Malus", "Golob", "Hrastel", "Blatnik"};
- String[] imena = {"Jure", "Lea", "Teja", "Tadej", "Jakob", "Anže", "Leon"};
- rnd = new Random();
- priimek = priimki[rnd.nextInt(priimki.length)];
- ime = imena[rnd.nextInt(imena.length)];
- letoR = rnd.nextInt(2018 - 1900) + 1900;
- }
- public interface Comparable{
- public int compareTo(Object o);
- }
- public Oseba(int args){
- int attribute = 0;
- Scanner scanner = new Scanner(System.in);
- System.out.println("By what attribute you wan't to edit? 1 for name, 2 for surname, 3 for year of birth.");
- attribute = scanner.nextInt();
- int direction = 0;
- System.out.println("In which direction you wanna edit array? 1 for normal, 2 for reverse");
- direction = scanner.nextInt();
- scanner.close();
- Oseba newPerson = new Oseba();
- String ime = newPerson.ime;
- Oseba newPers = new Oseba();
- String ime2 = newPers.ime;
- Oseba newPerson2 = new Oseba();
- int leto = newPerson2.letoR2;
- Oseba newPers2 = new Oseba();
- int leto2 = newPers2.letoR2;
- Oseba newPerson3 = new Oseba();
- String priimek = newPerson3.priimek;
- Oseba newPers3 = new Oseba();
- String priimek2 = newPers3.priimek;
- if(attribute == 3){
- if(leto < leto2){
- int temp = leto2;
- leto2 = leto;
- leto = temp;
- }
- }
- else if(attribute == 1){
- if ( ime.compareTo(ime2) < 0) {
- String temp = ime2;
- ime2 = ime;
- ime = temp;
- }
- }
- else if (attribute == 2){
- if (priimek.compareTo(priimek2) < 0){
- String temp = priimek2;
- priimek2 = priimek;
- priimek = temp;
- }
- }
- }
- public int compare(Oseba o){
- return this.ime.compareTo(o.ime);
- }
- public void bubblesort(Comparable[] a){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement