Advertisement
lincruste

Le jazz et le java

Jan 1st, 2014
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. // Jazz chords generator
  2. // par flyinghome83 et lincruste.
  3. // écrit entre le 31/12/2013 et le 01/01/2014
  4.  
  5. public class Accord {
  6.   public static void main (String[] args) {
  7. // Création d'un tableau de notes fondamentales
  8.     String[] Note = {"A", "B", "C", "D", "E", "F", "G"};
  9. // Création d'un tableau d'altérations
  10.     String[] Alteration = {"#", "b", ""};
  11. // Création d'un tableau de natures d'accords
  12.     String[] Nature = {"m", "-7", "-9", "-11", "-Maj7", "7sus4", "7sus4b9", "-6", "-b6", "-7b5", "o", "6", "M9", "Maj7", "Maj7#11", " ", "+", "7", "7b9", "7#11", "7#9", "7#9#11", "13", "13b9", "7add4", "alt", "9", "Maj7sus4"};
  13. // Extraction du nombre de valeurs de chaque tableau
  14.     int notelength = Note.length;
  15.     int altlength = Alteration.length;
  16.     int naturelength = Nature.length;
  17. // Choix aléatoire d'un nombre pour chaque tableau en fonction du nombre de valeurs
  18.  
  19.     int rand1 = (int) (Math.random() * notelength);
  20.  
  21.     int rand2 = (int) (Math.random() * altlength);
  22.  
  23.     int rand3 = (int) (Math.random() * naturelength);
  24.  
  25. // Création de l'accord par concaténation d'une chaîne de caractères composée de trois
  26. // éléments des tableaux choisis au hasard
  27.     String accord = Note[rand1] + Alteration[rand2] + Nature[rand3];
  28. // Affichage de l'accord créé
  29.       System.out.println(accord);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement