Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.lexepi;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.Scanner;
- public class registerpassword {
- public static void main(String[] args){
- System.out.println("Bienvenue !");
- System.out.println("Pour commencer, écrivé(e) le mot clé: ");
- //variable pour récupérer la valeur
- Scanner scgame = new Scanner(System.in);
- //nom de la catégorie
- String motcle = scgame.nextLine();
- System.out.println("Nom du jeu: ");
- //nom du jeu
- String game = scgame.nextLine();
- System.out.println("Entrer le site internet:");
- //lien du site
- String site = scgame.nextLine();
- System.out.println("Nom d'utilisateur:");
- //nom d'utilisateur
- String username = scgame.nextLine();
- System.out.println("Mot de passe: ");
- //mot de passe
- String password = scgame.nextLine();
- System.out.println("\nRécapitulatif:");
- System.out.println("Nom: "+motcle);
- System.out.println("\nJeu: "+game);
- System.out.println("\nSite internet: "+site);
- System.out.println("\nNom d'utilisateur du site/jeu: "+username);
- System.out.println("\nMot de passe du site/jeu: "+password);
- System.out.println("\nA / R: ");
- char reponse = scgame.nextLine().charAt(0);
- while(reponse != 'A' && reponse != 'R'){
- System.out.println("Merci d'accepter ou de refuser en écrivant: 'A' ou 'R'");
- reponse = scgame.nextLine().charAt(0);
- }
- if(reponse == 'A'){
- System.out.println("Merci, votre compte a bien été enregistré !");
- FileWriter fw;
- try {
- fw = new FileWriter("accounts.txt",true);
- fw.write("nom: "+motcle+"\r\n");
- fw.write(" jeu: "+game+"\r\n");
- fw.write(" site: "+site+"\r\n");
- fw.write(" nom d'utilisateur: "+username+"\r\n");
- fw.write(" mot de passe: "+password+"\r\n");
- fw.close();
- }catch(IOException ioe){
- System.err.println("IOException: " + ioe.getMessage());
- }
- }
- if(reponse == 'R'){
- System.out.println("Au revoir et a Bientôt");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement