0

I'm making a User class for an app I'm working on. I'm still new to this, so I don't know how can I make it work without necessarily making an interface as a base. I just want to make it as pure code. This is what I have so far:

import java.util.Scanner; 
public class User {
    String userID;
    String firstName;
    String middleName;
    String lastName;
    String email;
    String passwd;
    String birthday;
    String address;
}

There needs to be a profile picture as well. How can I declare it?

For example, does the email have any restrictions? How do I know if it's a valid email address? (I'm planning on connecting to a SQL database via Xampp, and I'm using Android Studio as well.)

Jacob
  • 299
  • 1
  • 18
bphantom
  • 3
  • 3
  • For the email case, you can find the answer here: https://stackoverflow.com/questions/624581/what-is-the-best-java-email-address-validation-method – Eduardo Soares Jul 17 '18 at 14:18
  • I'd recommend wrapping `import java.util.Scanner; public class User {` in SO code blocks for readability. – Collin Barrett Jul 17 '18 at 14:42

1 Answers1

0

For the profile picture you have several options. You can either keep the address of the picture as either a String value or a java.nio.file.Path or a java.io.File value in the User class. This way whenever you need to show the image you can access the path read it and show it.

The other option is to keep the image data in an ImageIcon instance, if you are eventually going to show it on a JFrame:

javax.swing.ImageIcon icon = new javax.swing.ImageIcon("androidBook.jpg");
PashMic
  • 71
  • 1
  • 4