Exemple #1
0
        /// <summary>
        /// This builds the array to store the place identifiers which will be used throughout the process of building the crime scene
        /// </summary>
        public void BuildPlacesIdArray()
        {
            // define variables
            DataTable placesData;

            try
            {
                // get the place identifiers
                placesData = DataRetrieval.QueryDataResults("ED.GetPlaceId", DataRetrieval.ConnectionSql, true);

                // if records are returned then build the array
                if (placesData.Rows.Count > 0)
                {
                    // define the # of elements in the array
                    places = new char[placesData.Rows.Count];

                    // store the number of places
                    numberPlaces = placesData.Rows.Count;

                    // put the place identifiers in the array
                    for (int count = 0; count <= placesData.Rows.Count - 1; count++)
                    {
                        places[count] = Char.Parse(placesData.Rows[count]["PlacesId"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public void GetAnswers()
        {
            // declare variables
            DataTable answers;                          // data table to store answers to the questions

            try
            {
                // setup the parameter for the answer
                List <DAParameter> answerParam = new List <DAParameter>
                {
                    new DAParameter("@QuestionId", ParameterDirection.Input, SqlDbType.Int, (object)QuestionId)
                };

                // retrieve answers for the question
                answers = DataRetrieval.QueryDataResults("[ED].[GetQuestionAnswers]", DataRetrieval.ConnectionSql, answerParam);

                if (answers.Rows.Count > 0)
                {
                    // store the answers
                    for (int rowCount = 0; rowCount < answers.Rows.Count; rowCount++)
                    {
                        Answers.Add(new Answer(QuestionId, Int32.Parse(answers.Rows[rowCount]["AnswerId"].ToString()),
                                               answers.Rows[rowCount]["AnswerDesc"].ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        public void LoadPlaceInfo(char placesId)
        {
            try
            {
                // declare variables
                DataTable placesInfo;

                // setup the parameter
                List <DAParameter> placesParam = new List <DAParameter>
                {
                    new DAParameter("@PlacesId", ParameterDirection.Input, SqlDbType.Char, 1, (object)placesId)
                };

                // retrieve the suspect information
                placesInfo = DataRetrieval.QueryDataResults("ED.GetPlaceInfo", DataRetrieval.ConnectionSql, placesParam);

                // load the suspect information
                Id = Char.Parse(placesInfo.Rows[0]["PlacesId"].ToString());
                PlaceDescription  = placesInfo.Rows[0]["PlaceDesc"].ToString();
                LocationId        = 0;
                LocationName      = "";
                AreaId            = 0;
                AreaName          = "";
                WeaponId          = 0;
                WeaponName        = "None";
                OddMaleSuspect    = null;
                EvenMaleSuspect   = null;
                OddFemaleSuspect  = null;
                EvenFemaleSuspect = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #4
0
        /// <summary>
        /// Loads the information about the suspect such as their name, sex, occupation, etc.
        /// </summary>
        public void LoadSuspectInfo(int suspectId)
        {
            try
            {
                // declare variables
                DataTable suspectInfo;

                // setup the parameter
                List <DAParameter> suspectParam = new List <DAParameter>
                {
                    new DAParameter("@SuspectId", ParameterDirection.Input, SqlDbType.Int, (object)suspectId)
                };

                // retrieve the suspect information
                suspectInfo = DataRetrieval.QueryDataResults("ED.GetSuspectInfo", DataRetrieval.ConnectionSql, suspectParam);

                // load the suspect information
                Id                         = Int32.Parse(suspectInfo.Rows[0]["SuspectId"].ToString());
                FirstName                  = suspectInfo.Rows[0]["SuspectFName"].ToString();
                LastName                   = suspectInfo.Rows[0]["SuspectLName"].ToString();
                Occupation                 = suspectInfo.Rows[0]["SuspectOccupation"].ToString();
                Relationship               = suspectInfo.Rows[0]["SuspectRelationship"].ToString();
                MarriedId                  = Int32.Parse(suspectInfo.Rows[0]["SuspectMarriedId"].ToString());
                Sex                        = Char.Parse(suspectInfo.Rows[0]["SuspectSex"].ToString());
                SexName                    = Sex == 'M' ? "Male" : "Female";
                IsVictim                   = false;
                IsMurderer                 = false;
                VictimPlace                = 'X';
                MurdererPlace              = 'X';
                MurderWeapon               = 0;
                MurderWeaponName           = "None";
                AlibiPlace                 = null;
                AlibiShowLocation          = false;
                AlibiShowArea              = false;
                AlibiShowPlace             = false;
                AlibiShowOddMaleSuspect    = false;
                AlibiShowEvenMaleSuspect   = false;
                AlibiShowOddFemaleSuspect  = false;
                AlibiShowEvenFemaleSuspect = false;

                // load the questions for the suspect
                PopulateSuspectQuestions(suspectId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #5
0
        /// <summary>
        /// Get the total number of suspects
        /// </summary>
        public void GetNumberSuspects()
        {
            // declare variables
            DataTable suspectData;

            try
            {
                // get the number of suspects
                suspectData = DataRetrieval.QueryDataResults("ED.GetNumberSuspects", DataRetrieval.ConnectionSql, true);

                // store the number of suspects
                numberSuspects = Int32.Parse(suspectData.Rows[0]["NumberSuspects"].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        /// <summary>
        /// Populates the questions for this suspect
        /// </summary>
        /// <param name="suspectId"></param>
        public void PopulateSuspectQuestions(int suspectId)
        {
            // declare variables
            DataTable questions;                        // data table to store the questions

            try
            {
                // setup the parameter for the question
                List <DAParameter> questionParam = new List <DAParameter>
                {
                    new DAParameter("@SuspectId", ParameterDirection.Input, SqlDbType.Int, (object)suspectId)
                };

                // retrieve questions for the suspect
                questions = DataRetrieval.QueryDataResults("[ED].[GetSuspectQuestions]", DataRetrieval.ConnectionSql, questionParam);

                // loop through the questions and assign them to the suspect
                if (questions.Rows.Count > 0)
                {
                    // intialize generic list for questions
                    SuspectQuestions = new List <Question>();

                    // load questions for the suspect
                    for (int rowCount = 0; rowCount < questions.Rows.Count; rowCount++)
                    {
                        SuspectQuestions.Add(new Question(Int32.Parse(questions.Rows[rowCount]["SuspectId"].ToString()),
                                                          Int32.Parse(questions.Rows[rowCount]["QuestionId"].ToString()), questions.Rows[rowCount]["QuestionDesc"].ToString()));
                    }

                    // now get the answers for the questions
                    foreach (Question q in SuspectQuestions)
                    {
                        q.GetAnswers();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        /// <summary>
        /// Loads information about the places
        /// </summary>
        public void PopulatePlaceInfo()
        {
            // declare variables
            int weaponType = 1;

            int[]     randomPlaces;
            Place     placeWeapon;
            DataTable pla;
            DataRow   plaRow;

            try
            {
                // for each place load the basic information (place id, name)
                for (int count = 0; count < numberPlaces; count++)
                {
                    Places.Add(new Place(places[count]));
                }

                // we need to determine the location (east, west) and area (uptown, midtown, downtown) for each place
                // retrieve all combinations of locations and areas for the places
                pla = DataRetrieval.QueryDataResults("ED.GetPlacesLocationArea", DataRetrieval.ConnectionSql, true);

                // loop through each place and find its location and area
                foreach (Place p in Places)
                {
                    // find a random location and area and store it
                    plaRow         = pla.Rows[randomNumbers.Next(pla.Rows.Count)];
                    p.LocationId   = Int32.Parse(plaRow["LocationId"].ToString());
                    p.LocationName = plaRow["LocationDesc"].ToString();
                    p.AreaId       = Int32.Parse(plaRow["AreaId"].ToString());
                    p.AreaName     = plaRow["AreaDesc"].ToString();

                    // remove this row from the data table
                    pla.Rows.Remove(plaRow);
                }

                // now determine the location of the weapon for each place.  The weapon cannot be located where the victim's body is.
                // first generate an array with random numbers that represents each place
                randomPlaces = Enumerable.Range(0, numberPlaces).OrderBy(x => randomNumbers.Next()).ToArray();

                // now loop through the array and get the place of the .38 first then the .45  If the place is equal to where the
                // victim's body is we cannot use that
                for (int count = randomPlaces.GetLowerBound(0); count <= randomPlaces.GetUpperBound(0); count++)
                {
                    // get the location of the .38 or .45
                    if (Victim.VictimPlace != places[randomPlaces[count]])
                    {
                        // first get a potential place to hide the weapon
                        placeWeapon = Places.Find(delegate(Place p) { return(p.Id == places[randomPlaces[count]]); });

                        // now store the weapon in the place provided that place doesn't already have a weapon
                        if (weaponType == 1 && placeWeapon.WeaponId == 0)
                        {
                            // .38
                            placeWeapon.WeaponId   = 1;
                            placeWeapon.WeaponName = ".38";
                            place38Id = placeWeapon.Id;
                            weaponType++;
                        }
                        else if (weaponType == 2 && placeWeapon.WeaponId == 0)
                        {
                            // .45
                            placeWeapon.WeaponId   = 2;
                            placeWeapon.WeaponName = ".45";
                            place45Id = placeWeapon.Id;
                            weaponType++;
                        }
                    }

                    // exit loop
                    if (weaponType > 2)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }