package emailapp;
import java.util.Scanner;
public class Email {
private String firstName;
private String lastName;
private String department;
private String password;
private String alternativeEmail;
private int mailboxCapacity = 200;
private String email;
private String companyName = "HomeCo.com";
public Email(String firstName, String lastName){
this.firstName = firstName;
this.lastName = lastName;
//System.out.println("Email Created!:" + this.firstName + " " + this.lastName + " ");
this.department = setDepartment();
//System.out.println("Your Email Department: "+ this.department);
this.password = setPassword(8);
//System.out.println("Your Password Is: "+ this.password);
email = firstName.toLowerCase() + "." + lastName.toLowerCase() + "@" + department + "." + companyName;
//System.out.println("Your Email Address Is: "+ email);
}
private String setDepartment() {
System.out.print("CHOICES:\n1.Sales\n2.Development\n3.Accounting\n4.None Of The Above\n");
Scanner Input = new Scanner(System.in);
int choice = Input.nextInt();
if(choice == 1) {
return "sales";
}
else if(choice == 2) {
return "dev";
}
else if(choice == 3){
return "acct";
}
else {
return " ";
}
}
package emailapp;
public class EmailApp {
public static void main(String[] args) {
// TODO Auto-generated method stub
Email em1 = new Email("Rojin","Ebrahimi");
System.out.println(em1.showInfo());
}
}
I have written a mini email-generating app which uses 2 classes: a class called "Email" and another class called "EmailApp" (which includes the main one). It has been written in Eclipse and I'm trying to run my codes in cmd but I'm confused how to first compile it.
When I type:
javac EmailApp.java,
it keeps telling me this:
class Email is public, should be declared in a file named Email.java
These classes are inside a package called "emailapp.