Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP2511 Practice Exam (21T3) COMP2511 21T3 Practice Exam There are three parts, Part 1: Short Answer (30 marks). Part 2: Programming Questions (70 marks). Change Log Exam Conditions You can start reading the exam at 14:00 (2pm) Wednesday 1st December 2021 Sydney time (AEST). You can start typing at 14:00 (2pm) Wednesday 1st December 2021 Sydney time (AEST). You have until 17:00 (5pm) Wednesday 1st December 2021 Sydney time (AEST) to complete this exam. Only submissions before 17:00 (5pm) Wednesday 1st December 2021 Sydney time (AEST) will be marked. Except, students with extra exam time approved by Equitable Learning Services (ELS) can make submissions after 17:00 (5pm) Wednesday 1st December 2021 Sydney time (AEST) within their approved extra time. You are not permitted to communicate (email, phone, message, talk, social networks, etc.) with anyone during this exam, except COMP2511 staff. Again, please note that you are not permitted to get help from anyone except COMP2511 staff during this exam. You are not permitted to access web pages or other internet resources, except the following web pages (for the exam, the lecture notes and documentation): you can access and read this exam paper! you can access the course material available on the course webpage and your course work (your tut/lab solutions, assignment and project work). you can also access Java API available online at https://docs.oracle.com/en/java/javase/11/docs/api/index.html . You are not permitted to access any other papers, books or computer files, except for the following: this exam, your tut/lab solutions, assignment and project work for this course. You are not permitted to use code-synthesis tools such as GitHub Copilot and other similar tools. Importantly, please make sure that you submit your original work and don't copy! We will use sophisticated plagiarism software/techniques to detect any possible breaches. Even after you finish the exam, on the day of the exam, on the day of the exam do not communicate your exam answers to anyone. Some students have extended time to complete the exam. Do not place your exam work in any location, including file sharing services such as Dropbox or GitHub, accessible to any other person. Ensure during the exam no other person in your household can access your work. Your zpass should not be disclosed to any other person. If you have disclosed your zpass, you should change it immediately. Deliberate violation of exam conditions will be referred to Student Integrity as serious misconduct. During the exam: if you have a question or need clarification during the exam, please post a PRIVATE post on the Ed forum. Do not send a message to the lecturer (or tutors), you may not get a response. When posting a message to the forum, it's important that you provide all the required details. Failure to do this may result in delays in responding to your queries. if there is a correction, we will post a notice on the class webpage. So please check your email and also check the class webpage for possible corrections (if any) during the exam period. Notes: Answer all questions. Questions may not be worth equal marks. Questions may be answered in any order. All answers must be submitted online using the provided instructions in the respective questions. Please note that the topics covered in the final exam may be different to the topics covered in the Practice Exam structure and/or Practice Questions. Also, the marks distribution across topics may also vary. You do not need to draw any UML diagrams for this exam. Important Information for Online Assessments Before your final exam, you must read the section "Important Information for Online Assessments" available on the Special Consideration webpage. It offers information on what you should do if you experience a technical issue that is beyond your control and impacts on your ability to complete an assessment, and the other related topics. In particular, how and what to document for a special consideration application. Please also read the check list provided by UNSW Student Services & Systems, click here . During the Exam If you have a question or need a clarification during the exam, you can make a PRIVATE post on the Ed forum. Do not send a message to the lecturer (or tutors), you may not get a response. When posting a message to the forum, it's important that you provide all the required details. Failure to do this may result in delays in responding to your queries. To ensure that you are as prepared for your online exam as you can be, make sure you check each point listed in the "Online Exam Preparation Checklist". In particular, read the following sections: Fit to Sit Technical Issues Communication during the exam Sharing answers with others or posting them online Setting up the exam Follow the given steps below to install the exam, they are done this way to prevent load on gitlab. Download the git bundle Run the following commands to unpack it, make sure that you replace the zID with your one. git clone -b main /exam-sample.bundle exam-sample cd exam-sample git remote remove origin git remote add origin gitlab@gitlab.cse.unsw.EDU.AU:COMP2511/21T3/students/z555555/exam-sample.git You can check your responses by going to your unique repository (again replace the zID) https://gitlab.cse.unsw.edu.au/COMP2511/21T3/students/z555555/exam-sample NOTE: There are extra questions here; https://gitlab.cse.unsw.edu.au/COMP2511/21T3/sample-exam Short Answer (30 marks) Please place all your answers to the short answer questions in your answers.md file. Question 1 (5 marks) You are implementing a health application that monitors heart rate of a patient. If the heart rate of a patient is out of the required range, the application needs to inform all the relevant doctors and nurses. Doctors and nurses responsible for a patient may change over time. Give the most appropriate design pattern for the following situations, briefly justifying your answer. Question 2 (5 marks) A user bought an application that reads data in JSON format, and displays results on a web page. Later, the user realised that one of their data sources is in XML format. Unfortunately, the user does not have access to the source code of the application, so it is not possible to change the application. Give the most appropriate design pattern for the following situations, briefly justifying your answer. Question 3 (3 marks) Briefly explain the important differences between the Decorator Pattern and the Builder Pattern, as discussed in the lectures. Question 4 (3 marks) Which of the following statements is true? (There may be more than one). Justify your answer. Template Method lets subclasses redefine an algorithm, keeping certain steps invariants. Subclasses of the Template Method can redefine only certain parts of a behaviour without changing the algorithm's structure. A subclass calls the operations of a parent class and not the other way around. Template pattern works on the object level, letting you switch behaviours at runtime Question 5 (3 marks) Identify one code smell in this program. (1 mark) Identify and explain the most pertinent (problematic) design smell in this program. (2 marks) Question 6 (2 marks) In the project, what was the purpose of Milestone 1? What design and development methodologies does it combine? Question 7 (2 marks) Which of the following is correct? There may be more than one correct answer. List is a subtype of List. List matches List and List. The wildcard < ? extends Foo > matches Foo and any subtype of Foo, where Foo is any type. The wildcard < ? extends Foo > matches Foo and any super type of Foo, where Foo is any type. Question 8 (3 marks) class Animal { public String noise() { return "I make a noise"; } } class Dog extends Animal { @Override public String noise() { return "Woof woof"; } } Dog dog = new Dog(); Animal animal = dog; System.out.println(animal.noise()); What will the above program print? With reference to concepts surrounding inheritance, explain your answer. Question 9 (4 marks) public class Flight { /* @precondition age >= 0, name does not contain any spaces @postcondition The flight is booked */ boolean book(int age, String name) { // ... } } public class GoldFlight extends Flight { /* @precondition age >= 50, name does not contain any spaces @postcondition The flight is booked */ @Override boolean book(int age, String name) { // ... } } Is this valid inheritance? Justify your answer. Programming Questions There is a src directory which is where your solution should be, often we'll give you some basic stub code. 1) Business Rules Typically, in commercial programs, we want to carry out actions only when a set of rules are true. As a shorthand, these are called business rules. Let's assume we have the following operators and variables available: Operators: group operators (AND, OR). comparison operators (NOT BLANK, IS GREATER THAN). Variables: Is named LOOKUP. Constant values are labelled as simply just CONSTANT for example: "email", "phoneNumber", "mark", "responses", "invites", etc. variables can be one of the following types: Double, String. variables are looked up using a Map a link to the Javadoc's for Map is below. If the Map doesn't contain the variable, its value is null. https://docs.oracle.com/javase/8/docs/api/java/util/Map.html Possible business rules could be as simple as below: The following is true if "email" variable is not blank (blank meaning that it consists purely of whitespace, is empty string, or is null), or "phoneNumber" is not blank. { "Operator": "OR", "Args": [ { "Operator": "NOT BLANK", "Arg": { "Operator": "LOOKUP", "Arg": "email" } }, { "Operator": "NOT BLANK", "Arg": { "Operator": "LOOKUP", "Arg": "phoneNumber" } } ] } The following is true if "responses" variable is greater than 2 and either "email" is not blank or "phoneNumber" is not blank. { "Operator": "AND", "Args": [ { "Operator": "GREATER THAN", "Args": [ { "Operator": "LOOKUP", "Arg": "responses" }, { "Operator": "CONSTANT", "Arg": 2 } ] }, { "Operator": "OR", "Args": [ { "Operator": "NOT BLANK", "Arg": { "Operator": "LOOKUP", "Arg": "email" } }, { "Operator": "NOT BLANK", "Arg": { "Operator": "LOOKUP", "Arg": "phoneNumber" } } ] } ] } Business Rules always evaluate to a boolean value. For simplicity, we also only support very few operators in this example (the ones stated above). Furthermore, you can presume all constants are numeric (doubles). All transformations/groups/operator's behaviour is explained in detail below; Feel free to use these enums in your solution. public enum BusinessRuleOperators { /** * Given A, and B are either integers or doubles * evalutes to true if A > B else false. * * Should throw BusinessRuleException("Both arguments have to be numeric") * if either A or B isn't an integer or a double or if B isn't supplied. */ GREATER_THAN, /** * Is a unary operator returns false if the argument given is either * null or a string consisting purely of spaces (or is empty) otherwise it returns true. * * Hint: `string.isBlank()` will tell you if a string is empty/consists purely of spaces. * * If the type is an integer/boolean/double it should always return true. * * Ignores second argument if supplied. */ IS_NOT_BLANK; } public enum BusinessRuleGroupTypes { /** * Evaluates the two business rules supplied and if both are true evaluates to true * else it evaluates to false. */ AND, /** * Evaluates the two business rules supplied and if either are true evaluates to true * else it evaluates to false. */ OR; } Your task is to design a solution that allows a user to create arbitrary rules as shown above. You must design your solution using one or more of the design patterns discussed in the course such that it could be easily extended (for additional operators). You'll be filling in the stub provided in BusinessRuleMain.java which given a json string representing the input json rule it'll return a class implementing the business rule interface, which then given a dictionary representing the variables will resolve to a boolean. public interface BusinessRule { public boolean evaluate(Map values); } You can use either gson or org.json (both libraries we've provided throughout the term) to implement your solution. You must obey the following; - JSON data should be extracted into classes and you should not store any json objects You must also provide brief justification for your design choices in Q1.txt. Please note that it doesn't have to be very long, just a paragraph should suffice. You will be awarded marks for proper justifications. NOTE: It's likely that in the actual exam, you'll need to utilise some generics in the solution so make sure to study up on those questions as well. 2) Refactoring A service provider offers checkout services to the two most popular supermarkets in Australia: Coles and Woolworths. The starter code provided models a fully correct software solution for the checkout process. However, the code has significant design flaws. You need to do the following: In a file Q2.txt, briefly describe the Design Smells you identified, justify a series of refactoring choices both at low-level (code level) and high level (use a suitable design pattern, if required). Refactor the code to remove the Design Smells, and if required, use a design pattern(s) discussed in the course for refactoring. For this question: Note: in the actual exam you'll also have to extend the solution to add a design pattern, in this case it could be something like supporting a discount system that requires a decorator pattern or similar. We will provide a suite of tests for you. After refactoring, the behaviour of the system should remain unchanged (i.e. the tests should still pass unchanged). End

本站部分内容来自互联网,仅供学习和参考