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());
}
}
我写了一个迷你电子邮件生成应用程序,它使用2个类:一个名为“Email”的类和另一个名为“EmailApp”的类(包括主要类)。它是用Eclipse编写的,我正在尝试在cmd中运行我的代码,但我对如何首先编译它感到困惑。
当我键入时:
javac EmailApp.java,
它一直告诉我这个:
类 电子邮件 是公开的,应在名为 Email 的文件中声明.java
这些类位于名为“emailapp”的包中。
萧十郎
qq_花开花谢_0
相关分类