Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a5c9da9
refactor the sample of SRP in OOD.
ThomsonTang Jun 23, 2017
592e60b
refactor the sample
ThomsonTang Jun 23, 2017
3a5dd12
first
ISmallBlack Jun 25, 2017
c624979
测试编码
ISmallBlack Jun 25, 2017
bf6493b
前面的作业
ISmallBlack Jun 25, 2017
b9dcd70
srp homework
Jun 27, 2017
46f1749
read the file and resolve a line to a product.
ThomsonTang Jun 27, 2017
8bfc3ed
add a resource directory.
ThomsonTang Jun 27, 2017
adea855
ocp homework
Jun 28, 2017
171e348
UML作业(dice game / shopping)
MIMIEYES Jun 28, 2017
a0496c3
refactor srp
Jun 29, 2017
0ab140f
refactor the promotion email project.
ThomsonTang Jun 29, 2017
8d716de
refactor the promotion email project.
ThomsonTang Jul 2, 2017
35e5c7b
Merge pull request #474 from chasing95/master
onlyliuxin Jul 2, 2017
f69a583
第一次srp重构作业
Jul 2, 2017
431217d
第一次作业
em14Vito Jul 2, 2017
616cf8d
payroll
onlyliuxin Jul 4, 2017
e49ac3d
Merge pull request #478 from em14Vito/master
onlyliuxin Jul 4, 2017
d7270d2
Merge pull request #477 from imhuster/master
onlyliuxin Jul 4, 2017
96092ed
Merge pull request #1 from onlyliuxin/master
wluqing Jul 4, 2017
70023ec
Merge pull request #476 from ThomsonTang/master
onlyliuxin Jul 5, 2017
6dfa138
Merge pull request #470 from MIMIEYES/master
onlyliuxin Jul 5, 2017
67e4eb4
Merge pull request #463 from starlight0405/master
onlyliuxin Jul 5, 2017
16fbe95
desktop commit
wluqing Jul 5, 2017
731e7e1
commit test
wluqing Jul 5, 2017
f20bea2
commit test2
wluqing Jul 5, 2017
f03f7ba
commit test undo
wluqing Jul 5, 2017
9c5a25d
commit test
wluqing Jul 5, 2017
048230a
commit and push test
wluqing Jul 5, 2017
fd74ffc
undo commit
wluqing Jul 5, 2017
0d1fbd3
Merge pull request #482 from wluqing/master
onlyliuxin Jul 6, 2017
30d1cb3
Merge pull request #457 from ISmallBlack/master
onlyliuxin Jul 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.coderising.payroll;

public interface Affiliation {
public double calculateDeductions(Paycheck pc);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.coderising.payroll;

import java.util.Date;

public class Employee {
String id;
String name;
String address;
Affiliation affiliation;


PaymentClassification classification;
PaymentSchedule schedule;
PaymentMethod paymentMethod;

public Employee(String name, String address){
this.name = name;
this.address = address;
}
public boolean isPayDay(Date d) {
return false;
}

public Date getPayPeriodStartDate(Date d) {
return null;
}

public void payDay(Paycheck pc){

}

public void setClassification(PaymentClassification classification) {
this.classification = classification;
}
public void setSchedule(PaymentSchedule schedule) {
this.schedule = schedule;
}
public void setPaymentMethod(PaymentMethod paymentMethod) {
this.paymentMethod = paymentMethod;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.coderising.payroll;

import java.util.Date;
import java.util.Map;

public class Paycheck {
private Date payPeriodStart;
private Date payPeriodEnd;
private double grossPay;
private double netPay;
private double deductions;

public Paycheck(Date payPeriodStart, Date payPeriodEnd){
this.payPeriodStart = payPeriodStart;
this.payPeriodEnd = payPeriodEnd;
}
public void setGrossPay(double grossPay) {
this.grossPay = grossPay;

}
public void setDeductions(double deductions) {
this.deductions = deductions;
}
public void setNetPay(double netPay){
this.netPay = netPay;
}
public Date getPayPeriodEndDate() {

return this.payPeriodEnd;
}
public Date getPayPeriodStartDate() {

return this.payPeriodStart;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.coderising.payroll;

public interface PaymentClassification {
public double calculatePay(Paycheck pc);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.coderising.payroll;

public interface PaymentMethod {
public void pay(Paycheck pc);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.coderising.payroll;

import java.util.Date;

public interface PaymentSchedule {
public boolean isPayDate(Date date);
public Date getPayPeriodStartDate( Date payPeriodEndDate);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.coderising.payroll;

import java.util.Date;

public class SalesReceipt {
private Date saleDate;
private double amount;
public Date getSaleDate() {
return saleDate;
}
public double getAmount() {
return amount;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.coderising.payroll;

import java.util.Date;

public class TimeCard {
private Date date;
private int hours;

public Date getDate() {
return date;
}
public int getHours() {
return hours;
}
}
32 changes: 32 additions & 0 deletions students/1132643730/ood-assignment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.coderising</groupId>
<artifactId>ood-assignment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>ood-assignment</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>aliyunmaven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 版权 (c) 2017 palmshe.com
* 保留所有权利。
*/
package com.coderising.ood.ocp;

import com.coderising.ood.ocp.formatter.LogFormatter;
import com.coderising.ood.ocp.handler.LogHandler;

/**
* @Description:
* @author palmshe
* @date 2017年6月19日 下午9:10:02
*/
public class Logger {

private LogHandler logHandler;
private LogFormatter logFormatter;

public Logger(LogHandler handler, LogFormatter formatter){
this.logHandler= handler;
this.logFormatter= formatter;
}

public void log(String msg){
this.logHandler.handleLog(this.logFormatter.formatMsg(msg));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 版权 (c) 2017 palmshe.com
* 保留所有权利。
*/
package com.coderising.ood.ocp;

import com.coderising.ood.ocp.formatter.DateUtil;
import com.coderising.ood.ocp.formatter.LogFormatter;
import com.coderising.ood.ocp.handler.LogHandler;
import com.coderising.ood.ocp.handler.MailUtil;
import com.coderising.ood.ocp.handler.SMSUtil;

/**
* @Description:
* @author palmshe
* @date 2017年6月19日 下午9:36:38
*/
public class Main {

public static void main(String[] args) {
LogHandler sms= new SMSUtil();
LogHandler mail= new MailUtil();
LogFormatter date= new DateUtil();
Logger log= new Logger(sms, date);
log.log("hello world");
log= new Logger(mail, date);
log.log("hello coder");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.coderising.ood.ocp.formatter;

import java.util.Date;

public class DateUtil implements LogFormatter{

private String getCurrentDateAsString() {

return "current date: "+ new Date();
}

/* (non-Javadoc)
* @see com.coderising.ood.ocp.LogFormatter#formatMsg(java.lang.String)
*/
@Override
public String formatMsg(String msg) {
return getCurrentDateAsString()+ ", "+ msg;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* 版权 (c) 2017 palmshe.com
* 保留所有权利。
*/
package com.coderising.ood.ocp.formatter;

/**
* @Description:
* @author palmshe
* @date 2017年6月19日 下午9:07:00
*/
public interface LogFormatter {

String formatMsg(String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* 版权 (c) 2017 palmshe.com
* 保留所有权利。
*/
package com.coderising.ood.ocp.handler;

import java.io.Serializable;

/**
* @Description:
* @author palmshe
* @date 2017年6月19日 下午9:08:04
*/
public interface LogHandler extends Serializable{

void handleLog(String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coderising.ood.ocp.handler;

public class MailUtil implements LogHandler{

public void handleLog(String logMsg) {
System.out.println("MailUtil handle, msg= "+ logMsg);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* 版权 (c) 2017 palmshe.com
* 保留所有权利。
*/
package com.coderising.ood.ocp.handler;

/**
* @Description:
* @author palmshe
* @date 2017年6月19日 下午9:22:49
*/
public class PrintUtil implements LogHandler{

/* (non-Javadoc)
* @see com.coderising.ood.ocp.LogHandler#send(java.lang.String)
*/
@Override
public void handleLog(String msg) {
System.out.println("PrintUtil handle, msg= "+ msg);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coderising.ood.ocp.handler;

public class SMSUtil implements LogHandler{

public void handleLog(String logMsg) {
System.out.println("SMSUtil handle, msg= "+ logMsg);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.coderising.ood.srp;
import java.util.HashMap;
import java.util.Map;

public class Configuration {

static Map<String,String> configurations = new HashMap<String,String>();
static{
configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com");
configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com");
configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com");
}
/**
* 应该从配置文件读, 但是这里简化为直接从一个map 中去读
* @param key
* @return
*/
public static String getProperty(String key) {

return configurations.get(key);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coderising.ood.srp;

public class ConfigurationKeys {

public static final String SMTP_SERVER = "smtp.server";
public static final String ALT_SMTP_SERVER = "alt.smtp.server";
public static final String EMAIL_ADMIN = "email.admin";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.coderising.ood.srp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class DBUtil {

/**
* 应该从数据库读, 但是简化为直接生成。
* @param sql
* @return
*/
public static List query(String sql){

List userList = new ArrayList();
for (int i = 1; i <= 3; i++) {
HashMap userInfo = new HashMap();
userInfo.put("NAME", "User" + i);
userInfo.put("EMAIL", "aa@bb.com");
userList.add(userInfo);
}

return userList;
}
}
Loading