摘要: public class Vertices { private final boolean hasColor; private final boolean hasTexCoords; private final int vertexSize; private final FloatBuffer vertices; private final ShortBuffer indices; private final GL10 gl; public Vertices(GL10 gl, int maxVertices, int maxIndice... 阅读全文
posted @ 2012-01-08 21:41 LiLiNiuNiu 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 我们继续重构,接下来我们遇到的问题是switch语句,书上说最好不要在另一个对象的属性基础上运用switch语句。如果不得不使用,也应该在对象自己的数据上使用而不是在别人的对象上使用。我们看到Rental的getCharge()里边的switch语句中的选择条件是getMovie().getPriceCode(),所以我们需要将getCharge()放到Movie类中。下边是新增加的Movie中的getCharge()和修改过的Rental中的getCharge():// method in Moviepublic double getCharge(int daysRented) { ... 阅读全文
posted @ 2012-01-08 16:41 LiLiNiuNiu 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 首先我们看重构之前的,共有三个类,Customer,Movie,Rental。全都是自己写的数据类。// Rental: 表示某个顾客租了一部影片public class Rental { private Movie _movie; private int _daysRented; public Rental(Movie movie, int daysRented) { _movie = movie; _daysRented = daysRented; } public int getDaysRented() ... 阅读全文
posted @ 2012-01-08 09:29 LiLiNiuNiu 阅读(651) 评论(1) 推荐(0) 编辑