✅ how to move it to abstract class

IIt's_Sam12/26/2022
I want to move admin user name & adminpass to abstract class or method
The point is how to compare them to user input after that
Image
BBecquerel12/26/2022
Why do you want to make it abstract?
IIt's_Sam12/26/2022
Just because the Dr. In college want that lol 💔
IIt's_Sam12/26/2022
@Becquerel
BBecquerel12/26/2022
:PepeHands:
BBecquerel12/26/2022
college professors
BBecquerel12/26/2022
the way you would do it is like this
BBecquerel12/26/2022
public abstract class Login
{
  void Login();
}

public class AdminLogin : Login
{
  public void override Login()
  {
    // same as what you already have, including user input
  }
}

public class UserLogin : Login
{
  public void override Login()
  {
    // you can do this differently than in the AdminLogin class, assuming that users login differently to admins
  }
}


this lets you do this:

var logins = new List<Login>();

// We can treat both classes as if they were the same and put them in the same list.
logins.Add(new AdminLogin());
logins.Add(new UserLogin());

// Because we can treat both classes as if they are the same, we can call the methods common to both of them - the methods in the abstract class
foreach (var login in logins)
{
  login.Login();
}
Mmtreit12/26/2022
As an aside, let's talk about using a string to control your loop...
IIt's_Sam12/26/2022
@mtreit
What you want to talk about it?
IIt's_Sam12/26/2022
@Becquerel
I'm going to try it
Mmtreit12/26/2022
Use a boolean value directly
IIt's_Sam12/26/2022
I found this easier
You can call me
Baby junior 😂😎
IIt's_Sam12/26/2022
@mtreit
Mmtreit12/26/2022
Yes?
IIt's_Sam12/26/2022
Any content creator or book recommendations for be better in c# i will appreciate it 🙌🏻
@mtreit
Mmtreit12/26/2022
Have you done $helloworld ?
IIt's_Sam12/26/2022
@mtreit
I'm doing my first oop for college
So i get a step forward in base ideas
Mmtreit12/26/2022
The interactive course I linked is a good place to start to get familiar with C# as a language
IIt's_Sam12/26/2022
@Becquerel
I didn't know how to do it
It gives me many errors
BBecquerel12/26/2022
i don't know what those errors are