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;
- namespace BookNotes
- {
- class User
- {
- string login;
- string password;
- List<Note> notes;
- public User(string _login, string _password)
- {
- login = _login;
- password = _password;
- }
- public string Login
- {
- get
- {
- return login;
- }
- }
- public string Password
- {
- get
- {
- return password;
- }
- }
- public void AddNote(Note note)
- {
- notes.Add(note);
- }
- public void AddNotes(List<Note> _notes)
- {
- notes.AddRange(_notes);
- }
- }
- class Note
- {
- string note;
- User userId;
- Book bookId;
- public string _Note
- {
- get
- {
- return note;
- }
- set
- {
- if (note.Length > 0 && note.Length < 750)
- {
- note = value;
- }
- }
- }
- public User _userId
- {
- get
- {
- return userId;
- }
- set
- {
- userId = value;
- }
- }
- public Book _bookId
- {
- get
- {
- return bookId;
- }
- set
- {
- bookId = value;
- }
- }
- }
- class Book
- {
- List<Note> notes;
- private int bookId;
- private static int count;
- public Note noteS
- {
- get
- {
- return notes;
- }
- }
- public int idBook
- {
- get
- {
- return bookId;
- }
- }
- public Book()
- {
- count++;
- bookId = count;
- }
- public void AddNote(Note note)
- {
- notes.Add(note);
- }
- public void AddNotes(List<Note> _notes)
- {
- notes.AddRange(_notes);
- }
- }
- class System
- {
- User user;
- private static List<User> users = new List<User>();
- int status;
- public System(User _user)
- {
- user = _user;
- users.Add(user);
- }
- public int CheckId()
- {
- string answ = null;
- Console.WriteLine("Do you want to Login? \n\t\t Y/N");
- string descision = Console.ReadLine();
- if (descision == "Y" || descision == "y")
- {
- Console.WriteLine("Enter your user name :");
- answ = Console.ReadLine();
- Console.WriteLine("Enter Your Password: ");
- string userPasw = Console.ReadLine();
- while (true)
- {
- if (answ == user.Login && userPasw == user.Password)
- {
- status = 1;
- Console.WriteLine("You are logged");
- return status;
- break;
- }
- else
- {
- Console.WriteLine("User number or password is wrong, repeat your attempt");
- }
- }
- }
- else if (answ == "N" || answ == "n")
- {
- Console.WriteLine("Do you want to complete registration? \n\t\t Y/N");
- answ = Console.ReadLine();
- switch (answ)
- {
- case "Y":
- case "y":
- AddUser();
- status = 1;
- return status;
- break;
- case "N":
- case "n":
- Console.WriteLine("You will continue unlogged");
- status = 0;
- return status;
- break;
- }
- }
- }
- private int AddUser()
- {
- string answ = Console.ReadLine();
- switch (answ)
- {
- case "Y":
- case "y":
- Console.WriteLine("Enter Your Username: ");
- string userId = Console.ReadLine();
- Console.WriteLine("Enter Your Password: ");
- string userPasw = Console.ReadLine();
- User noviy = new User(userId, userPasw);
- users.Add(noviy);
- return status = 1;
- break;
- case "N":
- case "n":
- return status = 0;
- break;
- }
- }
- public void StatusChek(int status)
- {
- if (status == 0)
- {
- Console.WriteLine("You are not autorized. You may only add and read your own notes");
- }
- else if (status == 1)
- {
- Console.WriteLine("You are autorized. You may add notes, read your own notes and notes of other users");
- }
- }
- }
- class Screener
- {
- public void ShowAllNotes( List<Note> notes)
- {
- notes.ForEach(x => { Console.Write(x); });
- }
- public int ShowBookId(Book book)
- {
- return book.idBook;
- }
- public void ShowNote (Note note)
- {
- Console.WriteLine("Записка принадлежит книге с ID {0} \n Записка принадлежит пользователю с ID {1} \n Текст записки: \n {2}", note._bookId, note._userId, note._Note);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement