Implement common data structures and algorithms


Assignment Task:

Learning outcome 1: Use and develop abstract data types.

Learning outcome 2: Implement common data structures and algorithms.

Instructions:

The assignment must be a product of your own work, except for the use of resources supplied with the course, discussions conducted with the lecturers, and other assistance shown as acceptable in the section Assistance to Other Students below.

Project Requirements:

Part 1:

You are to develop a basic flocking simulation.

Utilize appropriate data types and algorithms to produce a solution to the problem.

Suggested algorithms are:

  • Move - Relative to user input
  • Move - Automatically
  • Lock - To a domain
  • Follow - Move to a target
  • Runaway - Move from a target
  • Collide - Basic collision of objects
  • Randomize - Add a random element

Part 2:

You are to implement a simple system to generate a 'Lucky Dip' Lottery Ticket.

The following Class diagram describes the relationship between the classes.

Tasks

The Lotto class should provide the following functionality:

  • Initialize an array of 6 integers.
  • Set the array to zero.
  • Generates 6 random numbers in a range 1 to 49 in the array.
  • Sort the numbers in the array in ascending order (utilise a bubble sort or relevant sort algorithm of your choice).
  • Format and display the numbers (number output in the range 1 to 9 should be preceded by a blank space) in the array.

The Program class should provide the following functionality:

  • Instantiate a Lotto class object.
  • Construct a Lottery Ticket that allows the customer to have as many (between 1 and 20) randomly generated Lucky Dips as they require on the same ticket.
  • Display the ticket and 'Lucky Dip' numbers to the screen in the correct format.

Array Exercise 1 - Fortune Predictor

Let's look at some examples of using arrays.

First make a new project called Predictor, then......

Create an array of strings called time Array with the following data:

  • thirty minutes
  • an hour
  • eight hours
  • twelve hours
  • a day
  • a week
  • a month
  • a year
  • a decade\

Create an array of strings called aspectArray with the following data:

  • finances
  • love life
  • career prospects
  • travel plans
  • relationships

Create an array of strings called effectArray with the following data:

  • fall apart
  • exceed your expectation
  • become awkward in an unexpected way
  • become manageable
  • become spectacular
  • come to a positive outcome

Create an array of strings called personaArray with the following data:

  • man
  • boy
  • woman
  • girl
  • dog
  • bird
  • hedgehog
  • singer
  • relative

Create an array of strings called featureArray with the following data:

  • pink hair
  • a broken goldenchain
  • scary eyes
  • long blond nose hair
  • very red lips
  • silver feet

Create an array of strings called consequenceArray with the following data:

  • avoid looking at directly
  • sing a sad song with
  • stop and talk to
  • dance with
  • tell a secret
  • buy a coffee

Create a Button click event and a TextBlock for output.

In the click event use a random number to select an element randomly from each of the strings, as the following example illustrates timeArray[number.Next(0, timeArray.Length)].

In the click event, add the arrays to the following string to build a basic fortune predictor (use theTextBlock to output the string):

Over a period of timeArray your aspectArray will effectArray.

This will come to pass after you meet a personaArray with featureArray who for some reason you find yourself obliged to consequenceArray.

Use the TextBlock string to also output the prediction as a text-to-talk message.

Now add an image to your application.

Finally... change the message and the content of the arrays to develop your own version of the application...

Array Exercise 2-Flocking and Arrays

Let's look at some examples of using arrays in our flocking algorithms.

Try utilizing the following code in your flocking algorithms.

Make a copy of your flocking project and try implementing the following code:

Image[] myImageArray = new Image[10];

myImageArray[0] = testImage1;

myImageArray[1] = testImage2;

myImageArray[2] = testImage3;

myImageArray[3] = testImage4;

myImageArray[4] = testImage5;

myImageArray[5] = testImage6;

myImageArray[6] = testImage7;

myImageArray[7] = testImage8;

myImageArray[8] = testImage9;

myImageArray[9] = testImage10;

Utils.Move_Lock_To_Grid(myImageArray[0],

TestGrid,

(10 / (double)number.Next(1, 20)) + 2,

ref testFlag1X, ref testFlag1Y);

for (int loop = 1; loop < myImageArray.Length; loop++)

{

Utils.Basic_Follow(myImageArray[loop],

myImageArray[0],

(10 / (double)number.Next(1,21)) + 1);

}

You can add more images to the array as needed.................

Array Exercises: Part 1

First let's make a project called LottoTicket a class called Lotto.

Let's start by implementing the following:

  • Create a new project called LottoTicket.

 

  • Create a Class called Lotto and implement the following (see code below):

o Create an array of typeint with6 elements as a field.

o Create a private Random randomNumber field.

o Initialize both the fields in your Constructor.

o Create a method calledGenerateNumbersand use it to fill the array with random numbers 1 to 49.

o Create a method calledPrintNumbers and use it to display each value in the array to the screen.

  • In your Program class implement the following (see code below)::

o Call your lotto class (row).

o Start to build the ticket text.

o Call the GenerateNumbers method.

o Call the PrintNumbers method.

o Finish building the ticket text.

  • Your interface should display the following:

o Window size locked to height 605 and width 422.

o TextBlock displaying "Enter number of rows (1 to 20)"

o TextBox called TextBoxTickets

o Button called ButtonSelect

o TextBlock called TextBlockTickets, height 504, width 365, font Courier New, FontSize 16 and bold

o Add an image and set opacity to get your interface looking like the example shown

Array Exercises: Part 2

Update the following in your Lotto Class.

In the GenerateNumbers()method uses a loop to add a random number to each of the 6 array elements.

In thePrintNumbers(TextBlockOutputTextBlock)use a loop toprint the 6 random numbers from the array.

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 3

Add the following to your application in the Lotto Class.

Add a method called SetNumbersToZero()that loops through the numbers array and sets the six numbers to zero.

Add a call to the SetNumbersToZeromethod (row.GenerateNumbers();).

Array Exercises: Part 4

Add the following to your application in the Lotto Class.

Update the PrintNumbers method so that number output in the range 1 to 9 should be preceded by a blank space.

You will need to use an if...else statement and two output strings here to achieve this.

Add to the MainWindow.xaml.cs file.

publicvoidPrintNumbers(TextBlockOutputTextBlock)

{

// Format and displays 6 numbers to the screen

for (int loop = 0; loop < 6; loop++)

{

// IF ELSE statement here

}

}

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 5

Now look at how the ticket should be displayed and change the code in the MainWindowfile to produce this output.

 

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 6

Now let's get some input from the user so we can generate as many lines of numbers as we require.

Add the following to your MainWindow:

  • A variable of type integer called Lucky Dips.
  • Get the number from the user.
  • Limit the selection to between 1 and 20
  • Loop through that number of Lucky Dips

Array Exercises: Part 7

Now in the Lotto Classimplement the public void GenerateNumbers() method fully, so that it loops through the numbers array and randomly generates six unique numbers between 1 and 49.

Array Exercises: Part 8

Now in the Lotto Classimplement the public void SortNumbers() method, so that it loops through the numbers array and sorts the numbers in ascending order.

Add a call to this method in your MainWindowfile.

Run your application and look at the output.

Make your academic life successful with the industry best subject matter experts of Algorithms and Data Structures Assignment Help service!

Tags: Algorithms and Data Structures Assignment Help, Algorithms and Data Structures Homework Help, Algorithms and Data Structures Coursework, Algorithms and Data Structures Solved Assignments 

Attachment:- Data algorithms.rar

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Implement common data structures and algorithms
Reference No:- TGS03052931

Expected delivery within 24 Hours