Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Secure User Class | Class Design and Encapsulation
C# OOP Class Construction Drills

bookChallenge: Secure User Class

Tarefa

Swipe to start coding

Write the entire User class so that it securely manages user credentials for a login system.

  • The user's password must be stored in a private field that cannot be accessed or modified directly from outside the class.
  • The username must be accessible and settable publicly using a property.
  • Provide a protected method that checks if a given password matches the stored password.
  • Implement a constructor that initializes both the username and the password.
  • Add a public method TryLogin that accepts an input password, checks it using the protected validation method, and prints either Login successful or Login failed to the console.
  • Use the correct access modifiers for all members to ensure security and correct visibility.
  • Do not include any code outside of the User class except for the provided Program class and Main method.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 6
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Secure User Class

Deslize para mostrar o menu

Tarefa

Swipe to start coding

Write the entire User class so that it securely manages user credentials for a login system.

  • The user's password must be stored in a private field that cannot be accessed or modified directly from outside the class.
  • The username must be accessible and settable publicly using a property.
  • Provide a protected method that checks if a given password matches the stored password.
  • Implement a constructor that initializes both the username and the password.
  • Add a public method TryLogin that accepts an input password, checks it using the protected validation method, and prints either Login successful or Login failed to the console.
  • Use the correct access modifiers for all members to ensure security and correct visibility.
  • Do not include any code outside of the User class except for the provided Program class and Main method.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 6
single

single

some-alt