Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP282 – Advanced Object-Oriented C Languages

Coursework 2 – C#

Deadline: Monday 15th  of May at 17:00

Last possible time to hand-in: Monday 29th  of May at 17:00

Weighting: 50%

Feedback: General feedback will be released shortly after the last possible time you can hand-in (see above). Personal feedback will be released around the same time, depending on how close to the last possible time to hand in you did hand in.

Compress your Visual Studio project into a single zip file and submit it via CodeGrade – CodeGrade is only used to make grading easier, but it will be done by hand. In particular, you will not get feedback when submitting. Penalties for late work will be applied in accordance with the Code of Practice on   Assessment.  You can submit multiple times. If you submit more than once, we will only look at and  mark the most recent, and late penalties will be based on your final submission.

Project Overview:

You will create a small Windows GUI application to draw lines and find their intersections. The project consists of several tasks, which you should tackle in order (except for the hard tasks at the end where any subset can be done, and the order is not important). Each non-hard task builds on the previous one. Do as much as you can and then submit your project.

Read through this entire document before you start coding, so you are aware of all the tasks and the overall structure of the program. In particular, if you are aiming for all tasks, look especially at the     last one, because otherwise you will likely need to redo quite a bit. Your solution should demonstrate your knowledge of C# and GUI development with Visual Studio.

Note: Much of the code will be generated for you by Visual Studio. We’ll mark the code you write.

User Interface & User Experience Design

Your application should look something like the screenshots shown on the next page. It doesn’t have to be identical, but it should have equivalent controls and buttons.

The solution is shown working and discussed in the accompanying video. Please watch this to get a good idea of how your application should behave.

Runtime errors gives down to -20%

If your program makes multiple distinct obvious runtime errors, you lose 20% (down to at least 40%) – meaning it keeps crashing even if you do not try to find errors. If your program makes some subtle runtime errors, you lose 5-10% (again, down to at least 40%) – depending on how subtle.

Solution without the last task

Solution with the last task

Part 1 (Worth 15%)

Task 1 – Line Class Definition (5%)

Create a Line class that stores two points and a line colour. Implement a constructor that takes appropriate parameters and stores them in the object. Also, implement the appropriate C# property getters and setters (incl. appropriate access modifiers). Finally, override the ToString() method for    the class so that it outputs information about the two points (we will output the line colour in some other way).

5%: Created Line class

Task 2 – Form Layout (10%)

Use the Visual Studio layout designer to create a form similar to one of the onesshown above. At this stage, the application should be runnable. Also, set up the design so that it is nice to work with, incl.  tab order and names of elements. When it’s run, the form window should be displayed without any   build errors, although it will not do anything apart from terminate correctly when the user closes the window.

10%: Made a nice layout

Part 2 (Worth 65%)

Task 3 – Adding Lines (5%+5%=10%)

Use a relevant C# container class to store Line objects. Implement the code that runs when the user clicks the Add button. Your code should retrieve the text entered into the First X, First Y, Second X    and Second Y boxes and convert them into a Line object (with some reasonable default colour). You should also update the GUI so the added lines appear in the large picture box area as well as the list view box (or similar). Use the format shown above on the previous page (or similar). If something is not entered correctly, make a suitable error message.

5%: Implemented Add button

5%: … with suitable error messages

Task 4 – Drawing lines (10%)

Every time you click twice in the picture box, a line should be drawn between the two points defined (it is easier and seems more sensible to do it on MouseUp, but you can also do it on click). This task   is about implementing that functionality. You should add the created Line object to the picture box   and the list view box (or similar).

10%: Can draw lines

Task 5 – Changing colour (5%)

You should implement the Color button. It should show a ColorDialog and then, if the user selects OK, change the default colour (i.e. the colour used in future lines) to the chosen colour. It should also set the Forecolor of the Color button to be the chosen colour.

Task 6 – Removing lines (5%+5%=10%)

Your code should find out which item in the list is currently selected (represented by the blue background) and remove it, when the Remove button is clicked. Also, set the selected index in the list to be an adjacent line. Make sure you remove the item from the list as well as the picture box. Be sure to check the index of the removed item to prevent runtime out-of-bounds errors and display      suitable error messages if there are problems.

5%: Implemented Remove button

5%: … reasonable error messages and the index updates in a sensible manner afterwards

Task 7 – Updating Lines (5%+5%=10%)

When the user clicks on an item in the visible list (or uses the keyboard to move up and down the     list), the text boxes should be updated to reflect the current selection and the Forecolor of the Color button should be set to the colour of the selected line.

Implement the code that runs when the user clicks the Update button. Your code should update the currently selected line with whatever is currently in the text boxes. You should update both the list  as well as the picture box. Again, make sure you do not get runtime out-of-bounds errors and make suitable error messages if there are problems.

5%: Implemented Update button (with error messages)

5%: Change fields to be the content of the selected row on click

Task 8 – Find intersections (10%+10%=20%)

Add the code that runs when the user clicks the Find Intersections button. You should calculate the intersections between each line and show a circle around every point intersection and a line if the   lines overlap in a line, in both cases using the default colour. There is a nice algorithm by Samos and Huey for this, running in time O(n log n + k), if there are n lines and k intersections, but you are just expected to use the naïve O(n2 ) solution where you try all possible pairs of lines (partly because Visual Studio 2019 does not have priority queues the new version does).

If you can not remember how to find the intersection of two lines, you can look at:

https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection

Note though that it just solves the case where they meet in a point and you will need to do something else if you want to find the line overlaps. You get 10% if you get it to work reasonably well (i.e. what you would do if you only looked at that Wikipedia page) with the last 10% if you   actually get it fully working.

10%: Implemented Find Intersections button with basic behaviour

10%: Find Intersections works fully correctly

Part 4 (Worth 10%+10%=20%) – Make the list a data grid view (or similar)

Task 9 – Data grid view

Change the list view or similar to be a data grid view. When done correctly, it should let you add/edit lines by simply clicking on them on the list and changing the content (new lines would be added by    making a new line at the end) and therefore you can remove the corresponding buttons. You should be able to change the colour by entering/clicking on the Color field of the row (i.e. display the             ColorDialog) and its current color should be displayed as the background colour of that row (so you would not change the Forecolor of the Color button). To be concrete, the line should be added when all entries of a row are of the right type (and the user has done editing – i.e. when CellEndEditing is   called) and be updated when all entries are of the right type (and the user has done editing) – if the  user does not update a line correctly, use the line before they started these edits.

10%: Used a fair implementation of a data grid view

10%: Did not make any errors

How to Submit

Locate your Visual Studio project folder and compress it into a single .zip archive. If you use any other format we won’t be able to extract and mark your work.

Rename the zip file to be your student id (and then .zip).

If you want to draw our attention to anything, make a comment in the code itself. We will not read

or mark any other documents.

Submit your archive via CodeGrade.

Marking Descriptors

We draw your attention to the standard Department Grade Descriptors, which are listed in the Student Handbook.