假设有一个公司要做产品套餐,即把不同的产品组合在一起,不同的组合对应不同的价格。最终呈现出来的效果是:把产品组合的所有元素呈现出来,并显示该组合的价格。 每个产品都有名称和价格,首先设计一个关于产品的抽象基类。 public abstract class ProductBase { public a...
分类:
其他好文 时间:
2014-09-08 09:37:36
阅读次数:
359
一、前言 之前一直在忙于工作上的事情,关于设计模式系列一直没更新,最近项目中发现,对于设计模式的了解是必不可少的,当然对于设计模式的应用那更是重要,可以说是否懂得应用设计模式在项目中是衡量一个程序员的技术水平,因为对于一个功能的实现,高级工程师和初级工程师一样都会实现,但是区别在于它们实现功能的可....
分类:
其他好文 时间:
2014-09-07 23:46:06
阅读次数:
354
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font ...
分类:
其他好文 时间:
2014-09-07 21:07:35
阅读次数:
247
正则表达式:主要用于对字符串进行模式识别,判断字符串是否符合要求的格式package everyDayPratise;import java.util.regex.Matcher;import java.util.regex.Pattern;public class RegexTest1{ p...
分类:
编程语言 时间:
2014-09-07 20:56:45
阅读次数:
232
迭代器模式的需求来自:需要对一些集合进行迭代,而迭代的方式可能有很多种。 说到迭代,动作大致包括设置第一个位置,获取下一个位置元素,判断是否迭代结束,获取当前位置元素,大致就这么些。把这些迭代动作封装到一个接口中。 public interface IIterator { void First();...
分类:
其他好文 时间:
2014-09-07 08:41:24
阅读次数:
193
假设有一个软件公司,每当有新产品推出,就把信息通知到一些客户。 把通知这个动作抽象成一个接口。 public interface IService { void Notif(); }客户如果想获得通知,就需要实现以上的接口。这里的客户被看作是观察者。 public class CustomerA :...
分类:
其他好文 时间:
2014-09-07 07:37:04
阅读次数:
202
/**
* Sets the port of the local Socks5 proxy. Default is 7777. If you set the port to a negative
* value Smack tries the absolute value and all following until it finds an open port.
...
分类:
其他好文 时间:
2014-09-07 03:18:54
阅读次数:
250
/**
* Sets the port of the local Socks5 proxy. Default is 7777. If you set the port to a negative
* value Smack tries the absolute value and all following until it finds an open port.
...
分类:
其他好文 时间:
2014-09-07 03:18:44
阅读次数:
207
多线程设计模式:1.Single Threaded Execution Pattern[同一时刻只允许一个线程操作]比喻:三个挑水的和尚,只能同一时间一个人过桥,不然都掉河里喂鱼了。总结:在多个线程同时要访问的方法上加上synchronized关键字。2.Immutable Pattern[变量赋值...
分类:
编程语言 时间:
2014-09-07 03:16:34
阅读次数:
216