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());
}
}
我写了一个小电子邮件生成应用程序,它使用两个类:
一个叫做“email”的类和另一个叫做“emailapp”的类(包括主类)。它是用eclipse编写的,我正试图用cmd运行我的代码,但我对如何首先编译它感到困惑。
当我打字时:
javac EmailApp.java,
它一直告诉我:
类email是公共的,应该在名为email.java的文件中声明。
这些类位于一个名为“emailapp”的包中。