Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Software Engineering For Students: A Programming Approach Part 25. This fully revised version of Doug Bell's Software Engineering: A Programming Approach continues to use the successful formula of the previous editions. The author's approach is to present the main principles, techniques and tools used in software engineering, one by one, chapter by chapter. This book is a unique introduction to software engineering for all students of computer science and its related disciplines. It is also ideal for practitioners wishing to remain current with new developments in the area | 218 Chapter 15 Object-oriented programming 15.3 Suppose that you were asked to design a new programming language for software engineering select and justify a mechanism for encapsulation select and justify a mechanism for modularity. 15.4 Explain what the term modularity means. Assess how well the following features of programming languages contribute to modularity methods classes. 15.5 Assess the generics feature. 15.6 Argue for and against pointers in a programming language. 15.7 Argue for and against automatic garbage collection. Answers to self-test questions 15.1 public void moveDown int amount y y amount 15.2 public int yCoord get return y 15.3 Methods creditAccount debitAccount calculatelnterest Properties currentBalance name 15.4 class Stack private Arraylist s new Arraylist public void push String item s.add 0 item public String pop String item String s.get 0 s.remove 0 return item Answers to self-test questions 219 15.5 class Bomb extends Sprite private Imageicon bombimage public Bomb int newX int newY int newSize x newX y newY size newSize bombimage new imageicon c bomb.jpg public void display Jpanel panel Graphics paper panel.getGraphics bombImage.paintIcon panel paper x y public void move y y - 20 15.6 public int sum ArrayList String list int total 0 for int i 0 i list.size i total total integer.parseint list.get i return total 15.7 Generics complicate the language. 15.8 There are many possible answers. Here are just two 1. a file sort program because you never know how long the file will be 2. A web browser program because you do not know in advance how big a web page will be. 15.9 In an array all items after the insertion point have to be moved down the array a time-consuming process. In a dynamic structure only the pointer in the immediately preceding item needs to be updated - a very fast operation. 15.10 Factor reliability development effort performance C poor greater faster Java good smaller unpredictable 220 Chapter 15 Object-oriented .