Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class ProfileSystem {
- public static void main(String[] args)throws IOException {
- Scanner input = new Scanner(System.in);
- int counter = 0;
- String fileName = "ProfileInfo.txt";
- FileReader fr = new FileReader(fileName);
- BufferedReader br = new BufferedReader(fr);
- String credentials [][] = new String[10][2];
- for(int k = 0;k < 10 ; k++){
- String Line = br.readLine();
- String split[] = Line.split(",");
- credentials [k][0] = split [0];
- credentials [k][1] = split [1];
- }
- System.out.println("\rSign-up/Log-in");
- String answer = input.nextLine();
- do{
- switch(answer){
- case"Sign-up":
- counter = 0;
- System.out.println("\rPlease input your new username >");
- String name = input.nextLine();
- try {
- FileWriter fw = new FileWriter(fileName, true);
- fw.write(name);
- fw.close();
- }
- catch(FileNotFoundException ex) {
- System.out.println("Unable to save account details " + fileName);}
- catch(IOException ex) {
- System.out.println("Error reading " + fileName);}
- System.out.println("\rInput new password >");
- String pw = input.nextLine();
- try {
- FileWriter fw1 = new FileWriter(fileName, true);
- fw1.write(","+pw);
- fw1.close();
- }
- catch(FileNotFoundException ex) {
- System.out.println("Unable to save account details " + fileName);}
- catch(IOException ex) {
- System.out.println("Error reading " + fileName);}
- System.out.println("What is your favourite genre of film?");
- String genre = input.nextLine();
- if(genre.equals("Comedy")){System.out.println("Here are some film recommendations: The Mask, Megamind, The Hangover, Shaun of the Dead and Ted. ");}
- if(genre.equals("Horror")){System.out.println("Here are some film recommendations: .");}
- if(genre.equals("Thriller")){System.out.println("Here are some film recommendations: . ");}
- if(genre.equals("Drama")){System.out.println("Here are some film recommendations: . ");}
- if(genre.equals("War")){System.out.println("Here are some film recommendations: Dunkirk, . ");}
- case"Log-in":
- counter = 3;
- boolean loginsuccess = false;
- boolean pwsuccess = false;
- System.out.println("Input your username >");
- String user = input.nextLine();
- System.out.println("Input your password >");
- String pass = input.nextLine();
- for (int i = 0; i < 10;i++){
- if(credentials[i][0].equals(user)){
- loginsuccess = true;
- if(credentials[i][1].equals(pw)){
- loginsuccess = true;}
- input.close();}}}}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement