写作COMPSCI 230、 辅导program语言编程、Java程序设计调试

” 写作COMPSCI 230、 辅导program语言编程、Java程序设计调试COMPSCI 230 AssignmentBounce: part III/IIIIntroductionThis is the final instalment of the Bounce project, and perhaps the most challenging. The emphasis ofBounce III is on working with design patterns and Javas Swing API. You are required to complete andextend the application in a way that makes appropriate use of design patterns. Bounce III is amodel/view application that presents three views of a shared model. Such applications arecommonplace and introduce the Need for views to be mutually consistent and synchronised with amodel whose state changes at run-time. Once you have completed the assignment tasks, you shouldhave an application that looks similar to that shown in Appendix 1.Assessment criteriaEach task is associated with Assessment criteria. To test that you have met the criteria, each task isassociated with CodeRunner tests. The tests include a mix of: tests that run your compiled code to check that it is functionally correct and, other tests that examine your source to ensure that conforms to object-oriented principles.CR3 submissions carry 90% of the marks, whereas the ADB submission carry the rest 10%.The marking scheme for CR3 questions is mentioned against each task. ADB submissions will bemarked based on whether your entire submitted code compiles and runs successfully to show theexpected GUI as per specifications given in assignment brief. As such, if your code passes all four CR3tests, and your code is showing the expected GUI in your IDE, submitting the full code should workfine at the markers end too. You can ensure this by carefully packaging, zipping and submitting theverified code to ADB as per the submission instructions given below.SubmissionFor part 3 of the assignment (A4 Bounce III), you must: (9 marks) pass the CodeRunner tests by Week 12 (Friday 11:59pm, 30 October 2020)o visit coderunner3.auckland.ac.nz.o under Assignments, you should access A4 Bounce III Quiz.o the quiz has a total of four questions, each of which would require you to paste thesource code of one or more of your classes that you wrote in your IDE to completeeach task.o Task 1 and Task 2 have one CR question each, and Task 3 has two CR questions.o You may click on Check for each question multiple times without any penalty.o You may however make only one overall CR submission for the whole quiz. (1 mark) submit your Source code (including the original Canvas code) to the AssignmentDrop Box (ADB adb.auckland.ac.nz) by Week 12 (Friday 11:59pm, 30 October 2020).o The code submission must take the form of one zip file that maintains the Bouncepackage structure.o You must name your zip file as YourUPI_230a4_2020.zip.o You may make more than one ADB submission, but note that every submission thatyou make replaces your previous submission.o Submit ALL your files in every submission.o Only your most recent submission will be marked.o Please double check that you have included all the files required to run your programin the zip file before you submit it. Your program must compile and run (through Java1.8).NOTE: It is highly Recommended to first complete all tasks in an IDE like Eclipse, and then onlyproceed to answer CR3 questions once you have finished writing working code for this iteration inyour IDE. However, if you did not complete at least one of the previous Bounce assignments, thenthis may not be advisable. Read the preparation section below for more.ConstraintsFor all 3 parts of the of the assignment, any changes you make to the Shape class hierarchy must notbreak existing code (e.g. the AnimationViewer class). In particular, class Shape must provide thefollowing public interface (note this is not the Java interface; here the term interface refers to theset of public methods in a class that may act as entry points for the objects of other classes) at alltimes: void paint(Painter painter) void move(int width, int height)PreparationYou will need to download the bounce-3.zip file from Canvas. The zip file includes the source code anda properties file. The properties file allows you to specify application properties that are read by theapplication.You are strongly Advised to construct a model of the application that captures the key classes,instances and their interactions. The model need not be proper UML informal diagrams that allowyou to discover, document and visualise the applications structure would be sufficient to obtain therequired understanding. It is common in industry to work on existing software projects, and an abilityto understand their structure is an important skill.You should copy all the files from the bounce package that you have developed for Bounce I and IIinto the bounce package of Bounce III. Specifically, these (Java) files are: Shape, RectangleShape,OvalShape, DynamicRectangleShape, ImageRectangleShape and NestingShape. You should replaceyour ImageRectangleShape class with that contained in the bounce-III.zip download.For students who did not complete Bounce I and II:- You can still proceed with Bounce III byimplementing the required Bounce III classes, and then testing and submitting them using CodeRunner.However, without the classes from Bounce I and II, your Bounce application wont compile outside ofCodeRunner. Also, without the classes for Bounce I and II, you wont be able to develop an executableBounce application. This means that you will forfeit ADB (1 out of 10 marks) for this assignment.If you did not complete any of the first two assignments, and you intend to write code to includethose previous shapes you should study the A2 and A3 review lectures on Canvas pages.Supplied codeThe Bounce III project is organised around five packages: bounce: This includes the Shape hierarchy classes, Painter and the classes and interfacesconcerned with the Shape model: ShapeModel, ShapeModelListener and ShapeModelEvent. bounce.bounceApp: This package contains the main Bounce application class andBounceConfig, Which provides a convenient way of accessing application properties. bounce.forms: Package bounce.forms contains GUI form classes that allow the user to specifyShape attribute values. These include ColourFormElement for specifying a Shapes colour,ImageFormElement for specifying a Shapes image file, and ShapeFormElement for specifyinggeneral Shape attributes such as width and height. In addition, this package containsFormHandler implementations that read form data and which instantiate particular Shapesubclasses. bounce.forms.util: This contains application-independent artefacts for building forms. Form,FormElement and FormHandler are basic interfaces for representing forms, form elementscontaining data fields, and form processing respectively. FormComponent andFormElementComponent are Swing component implementations of Form and FormElement.FormUtility is convenience class for laying out forms. Of the five Bounce packages, this is theone that you need to be least familiar with. bounce.views: This package includes the view classes for this application and their associatedadapters that link them to a ShapeModel.The supplied code makes the following assumptions about your bounce package code: Class Shape and all shape subclasses (other than ImageRectangleShape) have a 7-argumentconstructor that takes the following parameters in order: x, y, deltaX, deltaY, width, height andtext. The first 6 parameters are of type int, while text is of type String. Class DynamicRectangleShape has an 8-argument constructor that takes the followingparameters in order: x, y, deltaX, deltaY, width, height, text and colour. The first 6 parametersare of type int, text is a String and colours type is java.awt.Color.Once your code conforms to the above expectations, the project will still contain compilation errorsbecause the tasks have yet to be completed. Specifically, the following units will have compilationerrors: bounce.bounceApp.Bounce. This is the main application class. It requiresbounce.views.TreeModelAdapterWithShapeModelListener to be implemented. bounce.forms.TestImageShapeFormHandler. This test case requires you to implement classbounce.forms.ImageShapeFormHandler in Task 3. bounce.views.TreeViewer requires that bounce.views.TreeModelAdapter is implemented.Task 1: implement class bounce.views.TreeModelAdapterA key part of a ShapeModel object is its composite structure of Shapes. When completed, the Bounceapplication should include a hierarchical view of this composition structure. Rather than reinvent thewheel, it makes sense to reuse Swings JTree component that is tried and tested and which is intendedfor visualising hierarchical structures. However, there is an interface mismatch problem in that a JTreecomponent is not able to render ShapeModel objects directly. Rather, a JTree component can renderany TreeModel object. This problem of wanting to make incompatible objects work together iscommon in object-oriented software development and can be solved using the Adapter designpattern. Apply this design pattern so that you can display a ShapeModels shape composition using aJTree component.Once you have completed this task, you can run the demo program bounce.views.TreeViewer.Assuming your TreeModelAdapter class is correct, this program will display a ShapeModels shapecomposition.Hints Carefully study the API documentation for Swings TreeModel interface. You will spend lesstime on this task overall if you invest in some up-front activity to understand the TreeModelinterface. Many of the TreeModel methods have arguments of type Object that you will need to cast toShape and NestingShape. In implementing class TreeModelAdapter, be sure to use theinstanceof operator so that only safe casts are performed. Class TreeModelAdapter should define one constructor that takes as argument a referenceto an object of type ShapeModel. TreeModels valueForPathChanged() method can simply be implemented with an emptymethod body. This method is an event notification method that can safely be implementedlike this in the context of this task.TestingFrom the CodeRunner quiz named Bounce III, complete the first question: (3 marks) Bounce III TreeModelAdapter, which runs a series of tests on yourTreeModelAdapter class.Your code will need to pass all tests.Task 2: Implement class -bounce.views.TreeModelAdapterWithShapeModelListenerYour TreeModelAdapter class has leveraged the Swing framework, and with very little effort you havea robust means of visualising a ShapeModels shape composition. Awesome. However, theTreeModelAdapter class suffers from a limitation that prevents the Bounce application from workingcorrectly. Bounce is a model/view application, with the GUI showing three different views of aShapeModel instance. The problem is that while the AnimationView and TableViewAdapter viewsrespond to changes in the state of ShapeModel, an instance of the TreeModelAdapter class does not.Consequently, when a new Shape instance is added or an existing Shape object is removed from theShapeModel, the change is not reflected in the JTree component. Obviously, this is most undesirableas all views should offer consistent representations of a common model.Introduce a new class, TreeModelAdapterWithShapeModelListener, that extends yourTreeModelAdapter class such that a TreeModelAdapterWithShapeModelListener instance can bothrender a ShapeModels shape composition and respond to changes that occur in the ShapeModel.Using a TreeModelAdapterWithShapeModelListener instance, its connected JTree component willupdate its display whenever the ShapeModel changes. It is helpful to think of aTreeModelAdapterWithShapeModelListener object as follows: A TreeModelAdapterWithShapeModelListener object plays two roles: the model of a JTreecomponent, and the (non-visual) view (listener) of a ShapeModel. A TreeModelAdapterWithShapeModelListener object essentially transforms ShapeModelevents that is hears about into TreeModel events that it fires to its TreeModelListeners. In thecase of the Bounce application there is one such listener, the JTree component.Implement class TreeModelAdapterWithShapeModelListener to do the necessary. Once completedyou should have a functioning Bounce application. Once you have edited and deployed theapplications properties file, discussed below, run the application and enjoy the fruits of your labour.On startup the Bounce application attempts to read configuration information from the file namedbounce.properties. You should locate this file within your login directory. For home PCs runningWindows, the login directory is C:/Users/username, where username is replaced with yourusername. You should ensure that the shape classes property lists the fully qualified names of Shapesubclasses that you want the application to use. Essentially, the combo box on the GUI is populatedwith the names of the classes you specify for the shape classes property. Hence, when using theapplication you can specify the kind of shape you want to add to the animation. In specifying classnames for this property, each name should be separated by whitespace; note however that if namesare spread across multiple lines a \ character should end each line except the last. For example, thefollowing specifies that two classes should be loaded:shape classes = bounce.RectangleShape \\rbounce.NestingShapeHints Carefully study the Java 8.0 API documentation for Swings TreeModelListener interface andclasses TreeModelEvent and TreePath. Similarly to before, you will spend significantly lesstime on this task if you study the API pages first rather than rushing in and trying to hacksomething together. There is a reasonable amount of complexity in the TreeModelListener and TreeModelEvententities. Some of this complexity lies in the ability for a TreeModelEvent to describe multiplenode additions/removals/changes in a TreeModel. Note that yourTreeModelAdapterWithShapeModelListener class need only generate TreeModel events thatdescribe a single addition or removal of a Shape at a time. Hence, the childIndices and childrenarrays that form part of the state of a TreeModelEvent will always have a length of 1. Each node shown in the Bounce applications JTree component represents a composite orsimple shape instance within the ShapeModel object. Each node is labelled with the name ofthe Shape subclass that the node is an instance of. The JTree acquires the label value for eachnode by calling method toString() on each Shape instance it discovers through makingTreeModel calls on its model. Given that these label values are not subject to change in theBounce application, your TreeModelAdapterWithShapeModelListener class need not make anytreeNodesChanged() calls on registered TreeModelListeners. In other words, yourTreeModelAdapterWithShapeModelListener class has only to make treeNodesInserted() andtreeNodesRemoved() calls on registered listeners, thereby communicating new and removednodes, respectively. Class TreeModelAdapterWithShapeModelListener should define one constructor that takes asargument a reference to an object of type ShapeModel.TestingFrom the CodeRunner quiz named Bounce III, complete the second question: (3 marks) Bounce III TreeModelAdapterWithShapeModelListener, which runs a series of testson your class.Your code will need to pass all tests.Task 3: add class bounce.forms.ImageShapeFormHandlerThe Bounce III application allows images to be loaded and added to the animation. Key classes are: bounce.ImageRectangleShape. This is a Shape subclass that paints a given image. bounce.forms.ImageFormElement. An ImageFormElement allows the user to select aparticular image from disk that is to be displayed by an ImageRectangleShape. bounce.forms.SimpleImageShapeFormHandler. An instance ofSimpleImageShapeFormHandler processes data entered in form elementsShapeFormElement and ImageFormElement and uses this to instantiate anImageRectangleShape object.Class SimpleImageShapeFormHandler scales the image selected by a user based on theShapeFormElements width field value. ShapeFormElements height is ignored as the scaling operationmaintains the images aspect ratio.The problem with SimpleImageShapeFormHandler is that the loading and scaling operations whichare expensive for large images are performed by the Event Dispatch thread. The image processingthus causes the application to freeze and become unresponsive when working with large images.For this task, you should create a new class (bounce.forms.ImageShapeFormHandler) to moreappropriately load and scale the image using a background thread, and make the newImageRectangleShape instance available to the Event Dispatch thread. LikeSimpleImageShapeFormHandler, ImageShapeFormHandler should have a constructor that takesShapeModel and NestingShape parameters and should implement the FormHandler interface.Specific requirements Class ImageShapeFormHandler must use class SwingWorker as part of its implementation. Class ImageShapeFormHandler must implement the FormHandler interface.Once you have implemented ImageShapeFormHandler, you should edit the FormResolver class tochange method getFormHandler() to return an ImageShapeFormHandler rather than aSimpleImageShapeFormHandler. You can then run the Bounce application and have large imagesloaded and scaled in the background when creating ImageRectangleShape objects.Hints The logic for acquiring form data, loading and scaling the image, and instantiatingImageRectangleShape is provided in the existing SimpleImageShapeFormHandler class. Youcan reuse this without modification in ImageShapeFormHandler. Dont consider this to be acase of duplicating code in reality you would discard the naiveSimpleImageShapeFormHandler class. You will need a large image file (greater than 20MB) to effectively demonstrate yourImageShapeFormHandler implementation. One source of suitable images is httpss://effigis.com/en/solutions/satellite-images/satellite-image-samples/TestingFrom the CodeRunner quiz named Bounce III, complete the remaining questions: (2 marks) Bounce III ImageShapeFormHandler, which runs a series of tests on your class. (1 mark) Bounce III ImageShapeFormHandler (static analysis), which analyses your code.Your code will need to pass all tests.DebuggingI strongly recommend that you use Eclipse for all assignments, and use Eclipse debugging feature foryour assistance.ACADEMIC INTEGRITYThe purpose of this assignment is to help you develop a working understanding of some of theconcepts you are taught in the lectures.We expect that you will want to use this opportunity to be able to answer the corresponding questionsin the exam.We expect that the work done on this assignment will be your own work.We expect that you will think carefully about any problems you come across, and try to solve themyourself before you ask anyone for help.This really shouldnt be necessary, but note the comments below about the academic integrityrelated to this assignment:The following sources of help are acceptable: Lecture notes, tutorial notes, skeleton code, and advice given by us in person or online, withthe exception of sample solutions from past semesters. The textbook. The official Java documentation and other online sources, as long as these describe thegeneral use of the methods and techniques required, and do not describe solutions specificallyfor this assignment. Piazza posts by, or endorsed by an instructor. Fellow students pointing out the cause of errors in your code, without providing an explicitsolution.The following sources of help are NOT acceptable: Getting another student, friend, or other third party to instruct you on how to design classesor have them write code for you. Taking or obtaining an electronic copy of someone elses work, or part thereof. Give a copy of your work, or part thereof, to someone else. Using code from past sample solutions or from online sources dedicated to this assignment.The Computer Science department uses copy detection tools on all submissions. Submissions foundto share code with those of other people will be detected and disciplinary action will be taken. Toensure that you are not unfairly accused of cheating: Always do individual assignments by yourself. Never give any other person your code or sample solutions in your possession. Never put your code in a public place (e.g., Piazza, forum, your web site). Never leave your computer unattended. You are responsible for the security of your account. Ensure you always remove your USB flash drive from the computer before you log off, andkeep it safe.Concluding NotesNot everything that you will need to complete this assignment has or will be taught in lectures ofthe course. You are expected to use the Oracle Java API documentation and tutorials as part of thisassignment.Post any questions to Piazza or ask via Zoom (avoid emails) this way, the largest number of peopleget the benefit of insight!We may comment along the lines on Piazza to deal with any widespread issues that may crop up.Appendix 1 Screen shot of final Bounce application如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导