Sie sind auf Seite 1von 5

AUT University 406704: Program Design and Construction Mock Exam Paper October 2010 Read these instructions

first: This is a 2 hour paper. It has 100 marks. This is a closed book exam. You may not refer to reference materials or use a mobile phone or computer. You will not need a calculator. You must not confer with your fellow students. The exam is divided into two parts. Part A consists of short-answer questions. Part B consists of longer questions requiring you to design software. Each part carries 50 marks. Answer all questions in Part A. Attempt 2 questions from Part B. If you attempt more than 2 questions, all of your answers will be marked and your best two marks taken. Read all questions first. Plan how you will spend your time. You have a little over a minute to spend on each mark. If you do not know the answer to a question, complete other questions first then come back to it. Allow adequate time for completing Part B, where the questions are longer and carry more marks. You may answer the questions in any order. Clearly indicate the number of the question being answered in you answer book. Large amounts of text are not required in answers. Use short sentences, lists, and simple diagrams.

Part A - This section consists of short answer questions testing your knowledge and understanding of program design and construction. 1. Software development projects often look like a race to develop a computer program before the money available to do so runs out. a. [1 mark] What would a company usually expect to spend the most money on when developing software? b. [4 marks] Give two examples a software engineering techniques or technologies and for each say how it helps to reduce costs. 2. In the course of developing a computer program we make a number of decisions about what to do with our code. a. [3 marks] Bad decisions, or 'mistakes' can end up costing us money and threatening the success of our project. List two factors that are important in determining how expensive a mistake ends up being, and what kinds of software engineering techniques help us reduce these costs? b. [2 marks] There is a cost associated with making good decisions too, because we have to spend time and effort doing so. But sometimes this cost is unnecessary. Why, and what kinds of software engineering techniques help us reduce these costs? 3. Your software development project uses a version control system. a. [1 mark] what does a version control system do? b. [2 marks] list two routine activities involved in working with a version control system c. [2 marks] Identify two advantages to using a version control system. 4. Here is some code that a. [3 marks] Write a Java expression that will evaluate to true if all of the preconditions for this code are met. b. [2 marks] Write a Java expression that evaluates to true if the function x() does what we would expect from its name, and false otherwise. 5. a. [2 marks] Explain what is wrong with the following function for printing a countdown. b. [3 marks] Rewrite the function so that it works as expected without using recursion. 6. Functional decomposition breaks complex tasks down into smaller ones. Often this corresponds to the structure of a procedural program. Suppose we have a function printPartyInvitation() that takes the name and address of one of our friends, and creates a letter inviting that friend to a party. a. [3 marks] If printPartyInvitation() calls three subroutines to get its job done, and those subroutines have good names that reflect their function, what might they be called? b. [2 marks] Choose one of your subroutines from the previous answer, and suggest two further subroutines that it might call. 7. a. [4 marks] Java provides some standard exceptions that should be thrown when a method receives a parameter value that it cannot handle. Name two, and describe precisely when they should be thrown. b. [1 mark] When will the following piece of code not generate an AssertionError if its line

is reached in an executing Java program? 8. a. [1 mark] Give the Java code for initialising a reference variable with a new object of type java.lang.Object. b. [2 marks] How does inheritance reduce the cost of programming in an object-oriented language? c. [2 marks] How does encapsulation reduce the cost of programming in an object-oriented language? 9. a. [5 marks] The documentation of a design pattern is usually separated into a number of short sections, each of which gives some useful information about the pattern. Name five of these sections. b. [5 marks] Describe a design pattern that you know.

Part B - This part consists of four programming questions. Attempt at least two. 10. [25 marks] Convert the following structured program into a procedural program. Obey the following style guide: 1. All variables and procedures should have meaningful names 2. No procedure should contain more than one level of nesting in its structure 3. Procedures can only share information via parameters and return values (you cannot assume a variable is shared by two subroutines 4. Avoid duplicate code
System.out.println("Welcome to the romance compatibility checker!"); System.out.print("Enter your name: "); Scanner scanner = new Scanner(System.in); String a = scanner.next(); float t1 = 0; for(int n = 0; n < a.length(); n++) { int v = a.charAt(n) - 'a'; t1 += v;

} t1 = t1/a.length(); boolean y = true; while(y) {

System.out.print("Enter the name of your friend: "); String b = scanner.next(); float t2 = 0; for(int n = 0; n < b.length(); n++) { int v = b.charAt(n) - 'a'; t2 += v;

} t2 = t2/b.length(); float d = t1 - t2; if(d < -5) System.out.println("No, you are too good for them!"); else if(d > 5) System.out.println("No, they are too good for you!"); else System.out.println("Good match! You will be very happy!"); System.out.print("Check another name? (y/n): "); String r = scanner.next(); y = r.equalsIgnoreCase("y"); } System.out.println("Goodbye!");

13. [25 marks] A self-service supermarket checkout has a touchscreen to interact with the user. Write three user stories for the system. One user story should cover the whole process of checking out. Two more should cover smaller parts of the process in more detail. For each story, list the user decisions made in the story. For each decision list the information that the user needs to make the decision. Group the decisions into tasks and design task windows for each task. Sketch each window, and indicate the features that make it easy for the customer to use.

14. [25 marks] An 'outline editor' is a text editor that allows documents to be arranged into sections. A section has a title and can contain paragraphs of text, and other sections. A document is a section with no parent. Using a boxes and lines diagram (or UML class diagrams if you are familiar with them), sketch the design of an outline editor that uses the Model/View/Controller architecture. Show in the diagram the structure of the classes making up the model. Annotate your diagram to show where particular design patterns are used. Include additional design patterns in your architecture if they would add useful functionality. 15. [25 marks] Show how you would use test-first programming to develop a procedure to convert an integer representing the time in minutes since midnight to a string in 24 hours format hh:mm. Lay out your answer as follows: first write an assertion statement that tests the procedure (you don't need to show a whole JUnit test method); then show the procedure that you would write to make the assertion pass; then write another assertion; then show what the procedure would look like after you have changed it to make both previous assertions pass. Continue like this until you think you have enough tests and a correct implementation. Remember to always produce the least amount of code that will make the prior tests pass.

Das könnte Ihnen auch gefallen