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

CE203 ASSIGNMENT

2022

Credit:

30% of total module mark

Module Learning Outcomes Examined:

1)  Demonstrate  knowledge  of  core  Java  application  libraries.  3)  Write  Java programs with interactive graphical user interfaces (GUIs) . 5) Write Java programs that make efficient use ofthe Java collections package.

Submission Deadline:

Thursday 15/12/2022 before 11:59:59 (Week 11)

Submission will be via theFaseronline submission system

You  should refer to the Undergraduate  Students’  Handbook  for  details  of the departmental policy regarding late submission and university regulations regarding plagiarism; the work handed in must be entirely your own. It is expected that marking of the assignment will be completed within 3/4 working weeks of the submission deadline.

Introduction

This assignment involves writing a Java application using Swing and AWT GUI components and a Java collections data structure. This must be hand-coded by you. Ifyou use IntelliJ Idea or any other IDE you must not use the GUI Designer or any similar tool. Additionally, you should not use any other external libraries not part of the Java SE API. You should only base your program on Java Swing and AWT libraries. The submitted program must be runnable without dependencies on any external libraries not part of the Java SDK used for the module. The files should contain brief comments.

WARNING AND ADVICE ABOUT POSSIBLE ACADEMIC OFFENCES

Your solutions should be your own unaided work. You can make use of any of the programs from the CE203 lecture notes and the lab templates on Moodle. You may use  other  features  from  the  Java  Standard  Edition  Application  Programming Interface (Java SE API) including those not covered in CE203. You must NOT use any third-party classes (e.g., classes that are not provided as part of the Java SDK used for this module).

For   more   information,   please   see   the   University   pages   onplagiarismand theAcademic Offences Procedures.

DO  NOT  COPY  PROGRAM  CODE  FOR  THIS  ASSIGNMENT  FROM  ANOTHER STUDENT OR FROM THE INTERNET OR FROM ANY OTHER SOURCES. DO NOT LET OTHER STUDENTS COPY YOUR WORK

Write a frame-based application that allows the user to store and manipulate a list of  objects  of  type  PolygonContainer  for  which  incomplete  java  classes  are provided.

PolygonContainer class is defined with the following attributes:

Color pColor = Color.BLACK; - Colour of the polygon, set to a Colour object, default set to black

int pId = 000000; - Polygon ID should be a six digit non- negative integer, default value set to ‘000000 

int pSides; - Number of sides of the polygon, should be non- negative value

int pSideLengths; - Length of each side in pixels of the polygon, should be non-negative value

int polyCenX; - x value of centre point (pixel) of polygon when

drawn on the panel

int polyCenY; - y value of centre point (pixel of polygon when

drawn on the panel

int [] pointsX; - int array containing x values of each vertex

(corner point) of the polygon

int [] pointsY; - int array containing y values of each vertex

(corner point) of the polygon

PolygonContainer class contains incomplete methods that you will use to draw a polygon using the dimensions specified in the attributes.

In the code I have provided the incomplete methods and an explanation of the functionality that you will need to code for generating and displaying a polygon based on the input parameters provided by the user.

The drawn polygon should look like the figure below where I have labelled how each of the attributes relate to it.

 

The  incomplete  ContainerPanel  and  ContainerFrame  classes provide  a  starting point for you where the method structures and explanation for the functionality to draw polygons are given. Read though all the comments provided in the code.

The PolygonContainer  class  also  implements the  Comparable  interface  and  an incomplete compareTo() method is provided for you to also complete.

The layout of the GUI should be such that any buttons should be displayed at the bottom of the frame and user input should be provided using appropriate text fields that should be displayed at top of the frame. Here you may choose to display buttons and text fields in their own panels. The centre of the GUI should contain a panel to display the drawn polygon. Here you may choose to use and modify the ContainerFrame  and  ContainerPanel  classes  provided.  Any  other  application outputs should be displayed through print statements in the command window.

The application should provide functionality and corresponding GUI components that allow the user to do the following:

a)  Add a PolygonContainer object to a list data structure where the user input text fields should specify values for the number of sides, side length, colour and id).

b)  Search for and retrieve from the list a PolygonContainer object specified by its Id (using one of the input text fields). Draw the retrieved polygon on the central panel of the application. The polygon should be drawn using the dimension and colour attribute values specified in the retrieved PolygonContainer object.

c)  Sort and display the contents of the list (the sorted list of PolygonContainer objects) in ascending order of their Ids, in the command window. Here you

need to specify an appropriate compareTo() method in the PolygonContainer class and explore the use of Collections.sort() to automatically sort the contents of   the    list.    See    Java    API    and    an    example    of   using    it    here: https://www.geeksforgeeks.org/collections-sort-java-examples/ (note the use of generics).

Id  attribute  values  may  contain  only  whole  digits,  so  should  not  contain  any negative digits or other characters. The Ids should be a fixed length of 6 digits when  input  by  the  user.  You  should  not  allow  the  list  to  store  objects  with duplicate Ids.

For each action specified above an appropriate message should be displayed in the command window confirming the action, e.g.

“Polygon ‘126658’ has been added to the list .

An appropriate error message should be displayed for any failed action e.g.

The Polygon ‘12786n was not added to the list as a valid Id was not provided. 

The list for storing the PolygonContainer objects should be implemented using an ArrayList

User input exceptions should be captured by the program using exception handling or acceptable error checking.

You should aim to make your user interface easy to use with a clear layout that makes appropriate use of spacing between the displayed components.

You  many  have  defined  more  than  one  Java  class  for  your  application.  It  is normally good practice to save these in their own physical .java files. Your code should  contain  one  class  that  contains  your  main() method  from  where  the application executes. All your code files must be clearly identifiable with your student registration number as a comment on the first line of the code. You must check that the code runs prior to submitting it as marks will be lost if the markers are unable to compile and run the code.

Commenting the Programs

The programs should contain brief comments indicating what each method in the code does and what each instance variable is used for. You should not write many comments stating what individual lines of code do. In places it may be appropriate

to simply state what a block of code does (e.g. “check that the input is a valid Id”). The programs should be laid out neatly and be readable with clear indentation.

Program Testing Output

The program produced  should be  fully tested to  demonstrate that  each  of the features you are asked to implement is working correctly.

You are asked to include either a Word or PDF document where you clearly show for each feature the correct output of your code. This can be shown as a series of screenshots that demonstrate the correct response of the program to each button press or user input / button press event. For example, where you are asked to sort and  display  all the PolygonContainer  objects by  Ids  from the  list, you  should display a screenshot where this is shown to be correctly output on the command line following the button press event.

Please briefly explain or label the screenshots for each feature being tested for example: b), c)…’

The Word of PDF document should include your student registration number and should be named according to the following naming convention:

Assignment 1_Testing_RegNo_<registration number>.

Submission

You are required to submit the source code files. You are also requested to submit an executable Jar file of your application, you can find instructions of how to create  one here: https://www.jetbrains.com/help/idea/compiling-applications.html and in the tutorial provided in the assignments section on Moodle.

You  need to  also  include the  Word/PDF  file  containing your program testing output. All the files should be placed in a single folder, which should then be zipped for submission to Faser, i.e. the submission should be a single file in zip formatOther formats (e.g. rar format) and submissions without the source

code will not be accepted and will result in a mark of zero.

Assessors will need to be able to run your code as is without any modifications required. So, you must make sure that your code is able to run correctly prior to submission.

Marks will be awarded for following all the requirements (including naming of files,  layout  of the  interface  etc.)  and  applying  object-oriented  programming principles appropriately.

Marking Criteria

1. Program compiles and runs

/20%

2. Correct layout, display of GUI components and program outputs

/20%

-    Correct layout display of program outputs and correct display of drawn polygon on GUI panel using stored parameters and colour

 

3. Correct button functionality

/20%

-    Adding PolygonContainer objects to the list based on unique Id as specified

 

-    Search and retrieve a PolygonContainer object by its Id and display it

 

-    Display and Sort PolygonContainer objects by Id in ascending order as specified using Collections.sort()

 

-    Correct use of ArrayList java collections data structure

 

4. Exception handling or other acceptable error checking approach

/20%

5. Overall elegance and correctness of code

/20%

-    Commenting of code

 

-    Object-orientated approach including the use of Generics

 

Total

/100%

For each of the 5 marking criteria, marks will be awarded out of 20% based on the following bands:

Poor: <=8%

Satisfactory: 9-10%

Good: 11-13%

Excellent: 14-16%

Outstanding: 17-20%