USE C# in visual studio code
A crossword like the New York Times is a two-dimensional grid that is populated with answers to clues.
An Across answer only begins at a white square when the square to its left is either black or a boundary.
A Down answer only begins at a white square when the square above it is either black or a boundary.
For example, the answer to clue 71-across “Summers in Québec” is ETES and is placed in the four
squares from left to right beginning at 71. You will note that the square to the left of 71 is black.
One-letter answers, however, do not have clues and hence the grid is numbered as shown below. You
will also note that a New York Times crossword has no answer less than 3 letters.
Overview of Requirements for Part A
1) Initialize an NxN crossword grid with white squares.
2) Randomly populate the crossword grid with M black squares. The grid does not need to be
symmetric like the New York Times crossword.
3) Number the grid in the same manner as the two crosswords above.
4) Print out the numbers in sequence for the Across and Down clues (without the clues of course).
5) Print out the grid including the black squares and clue numbers.
6) Check whether the grid is symmetric.
Class Outlines (Square and Puzzle)
public enum TColor { WHITE, BLACK };
public class Square
{
public TColor Color { set; get; } // Either WHITE or BLACK
public int Number { set; get; } // Either a clue number or -1 (Note: A BLACK square is always -1)
// Initialize a square to WHITE and its clue number to -1 (2 marks)
public Square() { … }
}
public class Puzzle
{
private Square [9, 10] grid;
private int N;
// Create an NxN crossword grid of WHITE squares (4 marks)
public Puzzle(int N) { … }
// Randomly initialize a crossword grid with M black squares (5 marks)
public void Initialize(int M) { … }
// Number the crossword grid (6 marks)
// public void Number ( ) { … }
// Print out the numbers for the Across and Down clues (in order) (4 marks)
public void PrintClues() { … }
// Print out the crossword grid including the BLACK squares and clue numbers (5 marks)
public void PrintGrid() { … }
// Return true if the grid is symmetric (à la New York Times); false otherwise (4 marks)
public bool Symmetric() { … }
}
Part B: Strings
Background
The string in C# language is a standard reference type where each instance of string is a sequence of
characters beginning at position 0. In most languages, the string is implemented as a linear array, but
for this assignment, the string will be (re-)implemented as a singly-linked list of characters
Class Outline
public class MyString
{
private class Node
{
public char item;
public Node next;
// Constructor (2 marks)
public Node( … ) { … }
}
private Node front; // Reference to the first (header) node
private int length; // Number of characters in MyString
// Initialize with a header node an instance of MyString to the given character array A (4 marks)
public MyString(char[] A) { … }
// Using a stack, reverse this instance of MyString (6 marks)
public void Reverse() { Stack S; … }
// Return the index of the first occurrence of c in this instance; otherwise -1 (4 marks)
public int IndexOf(char c) { … }
// Remove all occurrences of c from this instance (4 marks)
public void Remove(char c) { … }
// Return true if obj is both of type MyString and the same as this instance;
// otherwise false (6 marks)
public override bool Equals(object obj) { … }
// Print out this instance of MyString (3 marks)
public void Print() { … }
}
Overview of Requirements for Part B
1) Design, implement, and test each of the above methods of your string class.
2) Implement a main program as well that creates a menu of options to test your methods. In
order to display and allow the user to choose among instances of MyString, store the instances
of MyString in a linear array