Advertisement
Lexepi

Untitled

Mar 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. package fr.lexepi;
  2.  
  3. import java.io.FileWriter;
  4. import java.io.IOException;
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class registerpassword {
  9.  
  10. public static void main(String[] args){
  11.  
  12.  
  13. System.out.println("Bienvenue !");
  14. System.out.println("Pour commencer, écrivé(e) le mot clé: ");
  15. //variable pour récupérer la valeur
  16. Scanner scgame = new Scanner(System.in);
  17. //nom de la catégorie
  18. String motcle = scgame.nextLine();
  19.  
  20. System.out.println("Nom du jeu: ");
  21. //nom du jeu
  22. String game = scgame.nextLine();
  23.  
  24. System.out.println("Entrer le site internet:");
  25. //lien du site
  26. String site = scgame.nextLine();
  27.  
  28. System.out.println("Nom d'utilisateur:");
  29. //nom d'utilisateur
  30. String username = scgame.nextLine();
  31.  
  32. System.out.println("Mot de passe: ");
  33. //mot de passe
  34. String password = scgame.nextLine();
  35.  
  36. System.out.println("\nRécapitulatif:");
  37. System.out.println("Nom: "+motcle);
  38. System.out.println("\nJeu: "+game);
  39. System.out.println("\nSite internet: "+site);
  40. System.out.println("\nNom d'utilisateur du site/jeu: "+username);
  41. System.out.println("\nMot de passe du site/jeu: "+password);
  42. System.out.println("\nA / R: ");
  43.  
  44. char reponse = scgame.nextLine().charAt(0);
  45.  
  46. while(reponse != 'A' && reponse != 'R'){
  47. System.out.println("Merci d'accepter ou de refuser en écrivant: 'A' ou 'R'");
  48. reponse = scgame.nextLine().charAt(0);
  49. }
  50.  
  51. if(reponse == 'A'){
  52. System.out.println("Merci, votre compte a bien été enregistré !");
  53.  
  54. FileWriter fw;
  55. try {
  56. fw = new FileWriter("accounts.txt",true);
  57. fw.write("nom: "+motcle+"\r\n");
  58. fw.write(" jeu: "+game+"\r\n");
  59. fw.write(" site: "+site+"\r\n");
  60. fw.write(" nom d'utilisateur: "+username+"\r\n");
  61. fw.write(" mot de passe: "+password+"\r\n");
  62. fw.close();
  63.  
  64. }catch(IOException ioe){
  65. System.err.println("IOException: " + ioe.getMessage());
  66. }
  67. }
  68. if(reponse == 'R'){
  69. System.out.println("Au revoir et a Bientôt");
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement