Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace NEA
- {
- class Program
- {
- static void Main(string[] args)
- {
- Register();
- }
- static void Register()
- {
- string usernameToFile = getUsername();
- string passwordToFile = getPassword();
- writeAccountToFile(usernameToFile,passwordToFile);
- //Local Function getUsername retrieves name, age and year group and forms the username
- string getUsername()
- {
- //Input name
- Console.Write("Enter name: ");
- string name = Console.ReadLine();
- //Input age
- Console.Write("Enter age: ");
- string age = Console.ReadLine();
- //Enter year group
- Console.Write("Enter year group: ");
- string yearGroup = Console.ReadLine();
- //Does the name contain less than 3 characters?
- string usernamePrefix;
- if (name.Length > 3)
- {
- usernamePrefix = name.Substring(0, 3);
- }
- else
- {
- usernamePrefix = name;
- }
- //Creating username
- string username = usernamePrefix + age;
- //Is the username a duplicate? CANNOT CREATE UNTIL ABLE TO WRITE TO FILE FOR FORMATTING REASONS
- /*
- string[] lines = File.ReadAllLines(@"C:\Users\maxto\Desktop\accounts.txt");
- foreach(string line in lines)
- {
- } */
- return username;
- }
- //Local Function getPassword retrieves the password from the user and checks that it is longer than 7 chars
- string getPassword()
- {
- //Input password
- Console.Write("\nEnter your new password: ");
- string password = Console.ReadLine();
- //Does the password contain 8 or more characters?
- if(password.Length < 8)
- {
- Console.WriteLine("Password must be at least 8 characters");
- getPassword();
- }
- return password;
- }
- //Local Function writeAccount will write the username and password to a file
- void writeAccountToFile(string username,string password)
- {
- Console.WriteLine("test");
- /*using (StreamWriter accountWriter = new StreamWriter(@"C:\Users\maxto\Desktop\accounts.txt"))
- {
- accountWriter.WriteLine();
- }*/
- }
- }
- }
- public class DebugVars
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement