Advertisement
Blizzardo1

Matrix

Nov 3rd, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.61 KB | None | 0 0
  1. // Copyright (c) 2012 Blizzardo1, All rights reserved.
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Text;
  6.  
  7. namespace Derpina
  8. {
  9.     class Program
  10.     {
  11.         class StringMatrix
  12.         {
  13.             public int XMax
  14.             {
  15.                 get;
  16.                 private set;
  17.             }
  18.  
  19.             public int YMax
  20.             {
  21.                 get;
  22.                 private set;
  23.             }
  24.  
  25.             public int ZMax
  26.             {
  27.                 get;
  28.                 private set;
  29.             }
  30.  
  31.             string[,,] matrix;
  32.  
  33.             /// <summary>
  34.             /// A New String Matrix on a Zero-Based Index
  35.             /// </summary>
  36.             public StringMatrix(int xLen, int yLen, int zLen)
  37.             {
  38.                 XMax = xLen;
  39.                 YMax = yLen;
  40.                 ZMax = zLen;
  41.  
  42.                 matrix = new string[xLen, yLen, zLen];
  43.             }
  44.  
  45.             /// <summary>
  46.             /// Gets Data from a specific point in the Matrix
  47.             /// </summary>
  48.             /// <param name="x">X Position</param>
  49.             /// <param name="y">Y Position</param>
  50.             /// <param name="z">Z Position</param>
  51.             /// <returns>Data from the specified Coordinates</returns>
  52.             public string GetData(int x, int y, int z)
  53.             {
  54.                 return matrix[x, y, z];
  55.             }
  56.  
  57.             /// <summary>
  58.             /// Deletes the Data from the specified coordinates
  59.             /// </summary>            
  60.             /// <param name="x">X Position</param>
  61.             /// <param name="y">Y Position</param>
  62.             /// <param name="z">Z Position</param>
  63.             public void DeleteData(int x, int y, int z)
  64.             {
  65.                 matrix[x, y, z] = null;
  66.             }
  67.  
  68.             /// <summary>
  69.             /// Copies the Data from one set of coordinates to another
  70.             /// </summary>
  71.             /// <param name="x">X Position</param>
  72.             /// <param name="y">Y Position</param>
  73.             /// <param name="z">Z Position</param>
  74.             /// <param name="tx">Destination X</param>
  75.             /// <param name="ty">Destination Y</param>
  76.             /// <param name="tz">Destination Z</param>
  77.             public void CopyData(int x, int y, int z, int tx, int ty, int tz)
  78.             {
  79.                 matrix[tx, ty, tz] = matrix[x, y, z];
  80.             }
  81.  
  82.             /// <summary>
  83.             /// Sets the Data in the coordinates specified
  84.             /// </summary>
  85.             /// <param name="x">X Position</param>
  86.             /// <param name="y">Y Position</param>
  87.             /// <param name="z">Z Position</param>
  88.             /// <param name="Data">The Data to be set</param>
  89.             public void SetData(int x, int y, int z, string Data)
  90.             {
  91.                 matrix[x, y, z] = Data;
  92.             }
  93.         }
  94.  
  95.  
  96.         static void Main(string[] args)
  97.         {
  98.             int TotalData = 0;
  99.             Random r = new Random();
  100.             StringMatrix m = new StringMatrix(6, 4, 2);
  101.            
  102.             for (int z = 0; z < m.ZMax; z++)
  103.             {
  104.                 for (int y = 0; y < m.YMax; y++)
  105.                 {
  106.                     for (int x = 0; x < m.XMax; x++)
  107.                     {
  108.                         printReturnFeed("Setting X={0:000} Y={1:000} Z={2:000}\r\nTotal Data Entered={3}", x, y, z, TotalData++);
  109.                         m.SetData(x, y, z, Guid.NewGuid().ToString());
  110.                     }
  111.                 }
  112.             }
  113.  
  114.             Console.WriteLine("\r\n\r\n");
  115.  
  116.             for (int z = 0; z < m.ZMax; z++)
  117.             {
  118.                 for (int y = 0; y < m.YMax; y++)
  119.                 {
  120.                     for (int x = 0; x < m.XMax; x++)
  121.                     {
  122.                         Console.WriteLine("[{0:000}, {1:000}, {2:000}] {3}", x, y, z, m.GetData(x, y, z));
  123.                        
  124.                     }
  125.                 }
  126.             }
  127.  
  128.             for (int z = 0; z < m.ZMax; z++)
  129.             {
  130.                 for (int y = 0; y < m.YMax; y++)
  131.                 {
  132.                     for (int x = 0; x < m.XMax; x++)
  133.                     {
  134.                         m.DeleteData(x, y, z);
  135.                         Console.WriteLine("[{0:000}, {1:000}, {2:000}] Data Deleted", x, y, z);
  136.                     }
  137.                 }
  138.             }
  139.  
  140.             for (; ; ) ;
  141.         }
  142.  
  143.         static void printReturnFeed(string Text, params object[] parameters)
  144.         {
  145.             Console.Write(Text, parameters);
  146.             Console.SetCursorPosition(0, 0);
  147.         }
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement