SHARE
TWEET

Untitled

a guest Nov 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Vertauschen {
  2.  
  3.     public static String[] vertauscheInhalt(String[] inhalt) {
  4.         String[] inhaltVertauscht = new String[inhalt.length];
  5.         for (int n = 0; n < inhalt.length; n++) {
  6.             inhaltVertauscht[n] = new String(inhalt[(inhalt.length - 1 - n)]);
  7.         }
  8.         return inhaltVertauscht;
  9.     }
  10.  
  11.     public static String[] vertauscheReferenz(String[] inhalt) {
  12.         String[] referenzVertauscht = new String[inhalt.length];
  13.         for (int n = 0; n < inhalt.length; n++) {
  14.             referenzVertauscht[n] = inhalt[inhalt.length - 1 - n];
  15.         }
  16.         return referenzVertauscht;
  17.     }
  18.  
  19.     public static boolean testInhaltGleich(String[] arg1, String[] arg2) {
  20.         boolean test = true;
  21.         for (int n = 0; n < arg1.length; n++) {
  22.             if (!(arg1[n].contentEquals(arg2[n]))) {
  23.                 test = false;
  24.             }
  25.         }
  26.         return test;
  27.     }
  28.  
  29.     public static boolean testReferenzGleich(String[] arg1, String[] arg2) {
  30.         boolean test = true;
  31.         for (int n = 0; n < arg1.length; n++) {
  32.             if (arg1[n] != arg2[n]) {
  33.                 test = false;
  34.             }
  35.         }
  36.         return test;
  37.     }
  38.  
  39.     public static void main(String[] args) {
  40.         String[] inhalt = vertauscheInhalt(args);
  41.         String[] referenz = vertauscheReferenz(args);
  42.  
  43.         if (!testInhaltGleich(inhalt, referenz)) {
  44.             System.out.println("Fehler: Inhalte stimmen nicht ueberein!");
  45.         } else {
  46.             System.out.println("Die Inhalte stimmen ├╝berein!");
  47.         }
  48.  
  49.         if (testReferenzGleich(inhalt, referenz)) {
  50.             System.out.println("Fehler: Referenzen muessen unterschiedlich sein!");
  51.         } else {
  52.             System.out.println("Die Referenzen sind unterschiedlich!");
  53.         }
  54.  
  55.     }
  56.  
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top