📄 customer.java
字号:
/*
* Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.mandarax.examples.crm.domainmodel;
/**
* Represents customers. Note that there are some method to get the turnover.
* These methods are used as functions to build the knowledge base.
* (rules like: if the turnover of a customer in the last 6 month was more than
* 500$ then ..".
* @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
* @version 3.4 <7 March 05>
* @since 1.2
*/
public class Customer extends BusinessObject {
private int id = 0;
private String firstName = "?";
private String name = "?";
public static Customer ROBERT_MUSIL = new Customer (1, "Robert", "Musil");
public static Customer KURT_VONNEGUT = new Customer (2, "Kurt", "Vonnegut");
public static Customer GRAHAM_GREENE = new Customer (3, "Graham", "Greene");
public static Customer THOMAS_MANN = new Customer (4, "Thomas", "Mann");
public static Customer UMBERTO_ECO = new Customer (5, "Umberto", "Eco");
public static Customer LUDWIG_WITTGENSTEIN = new Customer (6, "Ludwig", "Wittgenstein");
public static Customer[] ALL = {ROBERT_MUSIL,KURT_VONNEGUT,GRAHAM_GREENE,THOMAS_MANN,UMBERTO_ECO,LUDWIG_WITTGENSTEIN};
/**
* Constructor.
*/
public Customer() {
super ();
}
/**
* Constructor.
* @param anId int
* @param aFirstName java.lang.String
* @param aName java.lang.String
*/
public Customer(int anId, String aFirstName, String aName) {
super ();
id = anId;
firstName = aFirstName;
name = aName;
}
/**
* Get the first name.
* @return java.lang.String
*/
public String getFirstName() {
return firstName;
}
/**
* Get the id.
* @return int
*/
public int getId() {
return id;
}
/**
* Set the id.
* @param id the id
*/
public void setId(int id) {
this.id = id;
}
/**
* Get the name.
* @return java.lang.String
*/
public String getName() {
return name;
}
/**
* Get the turnover during the last months.
* @return double
* @param month int
*/
public double getTurnover(int month) {
// WARNING: pure dummy data - would probably be fetched from a DB in a real project (using a GROUP BY query)
// this method is used as JFunction, see Oryx for another flavor of this example that uses SQLFunctions wrapping
// SQL queries on a CUSTOMER_TRANSACTION table
if (month>10) {
if (id==1) return 80;
else if (id==2) return 100;
else if (id==3) return 150;
else if (id==4) return 220;
else if (id==5) return 300;
else if (id==6) return 420;
}
return 1000;
}
/**
* Get the turnover in the last numberOfMonth
* using the kind of payment.
* @return double
* @param month int
* @param kop KindOfPayment
*/
public double getTurnover(int month, KindOfPayment kop) {
// WARNING: pure dummy data - would probably be fetched from a DB in a real project (using a GROUP BY query)
// this method is used as JFunction, see Oryx for another flavor of this example that uses SQLFunctions wrapping
// SQL queries on a CUSTOMER_TRANSACTION table
if (month>10) {
if (id==1) return 50;
else if (id==2) return 50;
else if (id==3) return 100;
else if (id==4) return 220;
else if (id==5) return 200;
else if (id==6) return 300;
}
return 1000;
}
/**
* Set the first name.
* @param aFirstName java.lang.String
*/
public void setFirstName(String aFirstName) {
firstName = aFirstName;
}
/**
* Set the name.
* @param aName java.lang.String
*/
public void setName(String aName) {
name = aName;
}
/**
* COnvert the object to a string.
* @return java.lang.String
*/
public String toString() {
return firstName + " " + name;
}
/**
* Compares objects.
* @return boolean
* @param obj java.lang.Object
*/
public boolean equals(Object obj) {
return obj!=null && (obj instanceof Customer) && ((Customer) obj).id == id;
}
/**
* Get the hash code of the object.
* @return int
*/
public int hashCode() {
return id;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -