COMP1010 - Fundamental of Computer Science Assignment

Download Solution Order New Solution

Assignment Task

Topics

  • Arrays
  • Searching in an array
  • Active Processing: setup() and draw()
  • State-driven programming
  • IF statement and nested IF
  • Relational Boolean operators
  • For loop
  • User-defined functions with different return types

Questions

1. Draw a valid Sudoku look

In this section, you will draw the look of a typical Sudoku. It will accept characters from the user and then draw those characters in the positions in the grid that are clicked on by the mouse. At the end of the assignment, the only valid inputs that should be accepted are digits between 1-9, but do not worry about that for this question! You will cover this in the next question. For this question, your program should be able to enter any character in the canvas, as long as there is an empty cell.

All the characters must be positioned at the center of a cell on the canvas. If the size of the canvas changes to other values between 100-900, with width and height always the same, the characters still have to be drawn at the center of the cells, and the text size should change to an appropriate size (not too big or too small).

In both Question 1 and Question 2, some numbers will already be in the grid when the program starts (place the blue numbers in the proper indexes of your array/s), and others will be entered by the user as in Question 1. Provide a suitable mechanism so that numbers that are there at the beginning will be drawn in a different color than the characters entered by the user. In the second question, you can delete a character that was enter by the user, but not the other numbers. Having a different colour makes it easy to spot the user-entered characters.

Purpose of the code

When the code runs, type a character with the keyboard and then click on an empty cell with the mouse. If the cell is empty, draw the character. If the cell is not empty, you shouldn’t be able to enter a character in the cell. By completing this question, your program should be able to map a mouse click on the canvas to the corresponding index in your array(s) (depends on your implementation).

2. A functional Sudoku with error detection

Save your DentStewA5Q1.pde program as DentStew_A5Q2.pde and then modify it. In this section, you will be completing your Sudoku which:

  • Detects any incorrect character (not 1-9) and does not allow it to be entered.
  • Detects any duplicates in a row, a column, or a 3x3 subgrid, notifies the player about the error, and does not accept the entry. o Use the JOptionPane class for showing the message.
  • Can remove a user-entered character (but not one that was there at the beginning) and make the cell available again. o Use the key ‘c’ on the keyboard for doing this.
  • Shows a winning message after the Sudoku is completely full, with valid entries.
  • Use the JOptionPane class for showing the message

This COMP1010Computer Science has been solved by our PHD Experts at My Uni Paper.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.