Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Date;
  5.  
  6. /**
  7.  * <p>  </p>
  8.  *
  9.  * @author: Савинов В.М.
  10.  * created: 31.03.2020
  11.  * @version: 0.0.1-SNAPSHOT
  12.  */
  13. public class Main<T extends Comparable<T>> {
  14.  
  15.     public static void main(String[] args) {
  16.         Main main = new Main();
  17.         main.testDateBubbleSort();
  18.         main.testStringBubbleSort();
  19.         main.testIntegerBubbleSort();
  20.     }
  21.  
  22.     private void testDateBubbleSort() {
  23.         final long currentTimeMillis = System.currentTimeMillis();
  24.         final Date now = new Date(currentTimeMillis);
  25.         final Date after = new Date(currentTimeMillis + 111111);
  26.         final Date before = new Date(currentTimeMillis - 111111);
  27.         final Date[] dates = {now, after, before};
  28.         testBubbleSort((T[]) dates);
  29.         printLine();
  30.     }
  31.  
  32.     private void testStringBubbleSort() {
  33.         String[] strings = {"keeek", "alo", "mmm"};
  34.         testBubbleSort((T[]) strings);
  35.         printLine();
  36.     }
  37.  
  38.     private void testIntegerBubbleSort() {
  39.         Integer[] integers = {1, 6, 2, 7, 2};
  40.         testBubbleSort((T[]) integers);
  41.         printLine();
  42.     }
  43.  
  44.     private void testBubbleSort(T[] testArray){
  45.         Arrays.stream(
  46.                 new Sorts<T>().bubbleSort(testArray))
  47.                 .forEach(System.out::println);
  48.     }
  49.  
  50.     private void printLine() {
  51.         System.out.println("================================");
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement