java—如何从另一个类借用示例变量

ppcbkaq5  于 2021-07-05  发布在  Java
关注(0)|答案(0)|浏览(166)

我目前正在努力获取连接到交互方法的lead\ id变量。这意味着lead在其自己的类中拥有所有的规范,但是,任务是将这个特定变量(lead\ id)链接到我目前正在创建的交互类。对于那些有点困惑的人。举个例子:

Lead output on console :
Lead_001,Jason,06-06-2005,Jason@gmail.com,Male,05158454
Interaction output on console:
Interaction_002,20-06-2005,Lead_001(this is what im trying to do),Jason@gmail.com,etc

以下是我目前的代码:
相互作用

enum Condition{
POSITIVE,
NEUTRAL,
NEGATIVE

}

class Interaction extends Lead_Class{
private int ID;
Condition condition;
private Date date;

public Interaction(int ID, String name, int phone, String email, String address, Date date, boolean isMale, int ID1, Condition condition, Date date1) {
    super(ID, name, phone, email, address, date, isMale);
    this.ID = ID1;
    this.condition = condition;
    this.date = date1;
}

@Override
public int getID() {
    return ID;
}

@Override
public void setID(int ID) {
    this.ID = ID;
}

public Condition getCondition() {
    return condition;
}

public void setCondition(Condition condition) {
    this.condition = condition;
}

@Override
public Date getDate() {
    return date;
}

@Override
public void setDate(Date date) {
    this.date = date;
}

public String toString() {
    return String.format("Interaction_00%s:%s,%s",
            ID,email,date);

}}
领导

class Lead_Class {
public int ID;
private String name;
private int phone;
public String email;
private String address;
private Date date;
private boolean isMale = false;

}

public Lead_Class(int ID, String name, int phone, String email, String address, Date date, boolean isMale) {
    this.ID = ID;
    this.name = name;
    this.phone = phone;
    this.email = email;
    this.address = address;
    this.date = date;
    this.isMale= isMale;
}
public int getID() {
    return ID;
}
public String getName() {
    return name;
}
public int getPhone() {
    return phone;
}
public String getEmail() {
    return email;
}
public String getAddress() {
    return address;
}
public Date getDate() {
    return date;
}
public boolean isMale() {
    return isMale;
}

public void setID(int ID) {
    this.ID = ID;
}

public void setName(String name) {
    this.name = name;
}

public void setPhone(int phone) {
    this.phone = phone;
}

public void setEmail(String email) {
    this.email = email;
}

public void setAddress(String address) {
    this.address = address;
}

public void setDate(Date date) {
    this.date = date;
}

public void setMale(boolean male) {
    isMale = male;
}

@Override
public String toString() {
    return String.format("Lead_00%s:%s,%s,%s,%s,%s,%s",
            ID,name,date,isMale,phone,address,email);
}

}
这是输入的发电机

public class Generator {

Lead_Class createGuest(int ID) throws ParseException {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter name: ");
    String name = scanner.nextLine();
    System.out.print("Enter your email: ");
    String email = scanner.nextLine();
    System.out.print("Enter your address: ");
    String address = scanner.nextLine();
    System.out.print("Enter the date of birth(dd-mm-yyyy):  ");
    String date = scanner.nextLine();
    SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
    Date userDate = format.parse(date);
    System.out.print("Enter your gender: ");
    String gender = scanner.nextLine();
    boolean isMale = Boolean.parseBoolean(gender);
    System.out.print("Enter your phone number: ");
    int phone = scanner.nextInt();
    return new Lead_Class(ID,name,phone,email,address,userDate,isMale);
}

Interaction createInteraction(int ID) throws ParseException{
    Scanner scanner1 = new Scanner(System.in);
    System.out.print("Enter the interaction day(dd-mm-yyyy):  ");
    String date = scanner1.nextLine();
    SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
    Date userDAte = format.parse(date);
    ?? (still haven't figured out)

}

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题