Example #1
0
        /// <summary>
        /// Add ths given element to the end of this list.
        /// </summary>
        /// <returns>The index at which the element was added or -1 if the element was not added.</returns>
        int IList.Add(object element)
        {
            var rc = list.Size();

            list.Add((T)element);
            return(rc);
        }
Example #2
0
 private void updateTiles()
 {
     for (int i = 0; i < tilearray.Size(); i++)
     {
         Tile t = (Tile)tilearray.Get(i);
         t.update();
     }
 }
Example #3
0
 public void testCount()
 {
     IList<string> list = new ArrayList<string>();
     list.Add("hoi");
     list.Add("noot");
     AssertEquals(2, list.Size());
 }
Example #4
0
        public void Init()
        {
            totest = new ArrayList <string>();
            totest.Add("a");
            totest.Add("b");

            //test Add
            totest.Add("c");
            Assert.AreEqual("c", totest.Get(2));

            //test Get
            Assert.AreEqual("b", totest.Get(1));

            //testSize
            Assert.AreEqual(3, totest.Size());

            //test IsEmpty
            Assert.AreEqual(false, totest.IsEmpty());

            //test Remove
            totest.Add("aa");
            String wtf = (String)totest.Get(0);

            Assert.AreEqual("a", wtf);
            Assert.AreEqual(false, totest.IsEmpty());
        }
Example #5
0
        public void testCount()
        {
            IList <string> list = new ArrayList <string>();

            list.Add("hoi");
            list.Add("noot");
            AssertEquals(2, list.Size());
        }
		public void setItems(ArrayList items) {
			for(int i = 0;i != items.Size();i++){
				//if(items.li == 1) {
					items.Set(i, "0" + items.Get(i));
				//}
			}
			this.items = items;
		}
Example #7
0
        public void Size_Test(int[] array, int expected)
        {
            ArrayList list = new ArrayList();

            list.AddAll(array);
            int actual = list.Size();

            Assert.AreEqual(expected, actual);
        }
 public void setItems(ArrayList items)
 {
     for (int i = 0; i != items.Size(); i++)
     {
         //if(items.li == 1) {
         items.Set(i, "0" + items.Get(i));
         //}
     }
     this.items = items;
 }
        public static IDictionary <string, object> ToDictionary(this IDictionary <string, Java.Lang.Object> map)
        {
            var dict = new Dictionary <string, object>();

            foreach (var key in map.Keys)
            {
                var value = map[key];
                if (value is Java.Lang.Boolean bln)
                {
                    dict.Add(key, bln.BooleanValue());
                }
                else if (value is Java.Lang.Long lng)
                {
                    dict.Add(key, lng.IntValue());
                }
                else if (value is Java.Lang.Integer integer)
                {
                    dict.Add(key, integer.IntValue());
                }
                else if (value is Java.Lang.Double dbl)
                {
                    dict.Add(key, dbl.DoubleValue());
                }
                else if (value is Java.Lang.String str)
                {
                    dict.Add(key, str.ToString());
                }
                else if (value is Java.Util.Date dt)
                {
                    var dtFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                    dict.Add(key, dtFormat.Format(dt));
                }
                else if (value.Class.IsInstance(new ArrayList()))
                {
                    if (value is System.Collections.ICollection collection)
                    {
                        var lst  = new List <string>();
                        var list = new ArrayList(collection);
                        for (var i = 0; i < list.Size(); i++)
                        {
                            var item    = list.Get(i);
                            var itemStr = item.ToString();
                            lst.Add(itemStr);
                        }
                        dict.Add(key, lst);
                    }
                }
                else
                {
                    dict.Add(key, value.ToString());
                }
            }

            return(dict);
        }
Example #10
0
 /// <summary>
 /// Invoke all handlers on the list.
 /// </summary>
 internal void Invoke(object sender, EventArgs args)
 {
     if (list != null)
     {
         var count = list.Size();
         for (var i = 0; i < count; i++)
         {
             list.Get(i)(sender, args);
         }
     }
 }
Example #11
0
        public GoalListAdapter(Context context)
        {
            this.context = context;

            while (goalListArray.Size() < 5)
            {
                System.Random random         = new System.Random();
                int           optionPosition = random.Next(goalListOptions.Length);
                String        goalListOption = goalListOptions [optionPosition];
                if (!goalListArray.Contains(goalListOption))
                {
                    goalListArray.Add(goalListOption);
                }
            }
        }
Example #12
0
        private void loadMap()
        {
            ArrayList <string> lines = new ArrayList <string>();
            int width  = 0;
            int height = 0;

            var scanner = new Scanner(SampleGame.map);

            while (scanner.HasNextLine)
            {
                string line = scanner.NextLine();

                // no more lines to read
                if (line == null)
                {
                    break;
                }

                if (!line.StartsWith("!"))
                {
                    lines.Add(line);
                    width = Math.Max(width, line.Length);
                }
            }
            height = lines.Size();

            for (int j = 0; j < 12; j++)
            {
                string line = (string)lines.Get(j);
                for (int i = 0; i < width; i++)
                {
                    if (i < line.Length)
                    {
                        char ch = line[i];
                        Tile t  = new Tile(i, j, char.GetNumericValue(ch));
                        tilearray.Add(t);
                    }
                }
            }
        }
Example #13
0
		private Integer SetVerticalCellRange(LinkedDataRecord linkedDataRecord,
				                             CellRangeAddressBase range) {
			if (linkedDataRecord == null)
			{
				return null;
			}
			
			List<Ptg> ptgList = new ArrayList<Ptg>();
			
			int rowCount = (range.GetLastRow() - range.GetFirstRow()) + 1;
			int colCount = (range.GetLastColumn() - range.GetFirstColumn()) + 1;
			
			for (Ptg ptg : linkedDataRecord.GetFormulaOfLink()) {
				if (ptg is AreaPtgBase) {
					AreaPtgBase areaPtg = (AreaPtgBase) ptg;
					
					areaPtg.SetFirstRow(range.GetFirstRow());
					areaPtg.SetLastRow(range.GetLastRow());
					
					areaPtg.SetFirstColumn(range.GetFirstColumn());
					areaPtg.SetLastColumn(range.GetLastColumn());
					ptgList.Add(areaPtg);
				}
			}
			
			linkedDataRecord.SetFormulaOfLink(ptgList.ToArray(new Ptg[ptgList.Size()]));
			
			return rowCount * colCount;
		}
Example #14
0
 public override int GetCount()
 {
     return(mTabs.Size());
 }
Example #15
0
        public void SizeTest(int[] original, int expected)
        {
            ArrayList list = new ArrayList(original);

            Assert.AreEqual(expected, list.Size());
        }
Example #16
0
 /// <summary>
 /// Get the object at the top of the Stack without removing it.
 /// </summary>
 public virtual T Peek()
 {
     return(list[list.Size() - 1]);
 }
Example #17
0
 public int Count()
 {
     return(_list.Size());
 }
Example #18
0
        private void updateRunning(IList <TouchEvent> touchEvents, float deltaTime)
        {
            // This is identical to the update() method from our Unit 2/3 game.

            // 1. All touch input is handled here:
            int len = touchEvents.Size();

            for (int i = 0; i < len; i++)
            {
                TouchEvent @event = touchEvents.Get(i);
                if (@event.type == TouchEvent.TOUCH_DOWN)
                {
                    if (inBounds(@event, 0, 285, 65, 65))
                    {
                        robot.jump();
                        currentSprite = anim.getImage();
                        robot.setDucked(false);
                    }

                    else if (inBounds(@event, 0, 350, 65, 65))
                    {
                        if (robot.isDucked() == false && robot.isJumped() == false &&
                            robot.isReadyToFire())
                        {
                            robot.shoot();
                        }
                    }

                    else if (inBounds(@event, 0, 415, 65, 65) && robot.isJumped() == false)
                    {
                        currentSprite = Assets.characterDown;
                        robot.setDucked(true);
                        robot.setSpeedX(0);
                    }

                    if (@event.x > 400)
                    {
                        // Move right.
                        robot.moveRight();
                        robot.setMovingRight(true);
                    }
                }

                if (@event.
                    type == TouchEvent.TOUCH_UP)
                {
                    if (inBounds(@event, 0, 415, 65, 65))
                    {
                        currentSprite = anim.getImage();
                        robot.setDucked(false);
                    }

                    if (inBounds(@event, 0, 0, 35, 35))
                    {
                        pause();
                    }

                    if (@event.x > 400)
                    {
                        // Move right.
                        robot.stopRight();
                    }
                }
            }

            // 2. Check miscellaneous events like death:

            if (livesLeft == 0)
            {
                state = GameState.GameOver;
            }

            // 3. Call individual update() methods here.
            // This is where all the game updates happen.
            // For example, robot.update();
            robot.update();
            if (robot.isJumped())
            {
                currentSprite = Assets.characterJump;
            }
            else if (robot.isJumped() == false && robot.isDucked() == false)
            {
                currentSprite = anim.getImage();
            }

            ArrayList <Projectile> projectiles = robot.getProjectiles();

            for (int i = 0; i < projectiles.Size(); i++)
            {
                Projectile p = (Projectile)projectiles.Get(i);
                if (p.isVisible() == true)
                {
                    p.update();
                }
                else
                {
                    projectiles.Remove(i);
                }
            }

            updateTiles();
            hb.update();
            hb2.update();
            bg1.update();
            bg2.update();
            animate();

            if (robot.getCenterY() > 500)
            {
                state = GameState.GameOver;
            }
        }
Example #19
-1
        private void loadMap()
        {
            ArrayList<string> lines = new ArrayList<string>();
            int width = 0;
            int height = 0;

            var scanner = new Scanner(SampleGame.map);
            while (scanner.HasNextLine())
            {
                string line = scanner.NextLine();

                // no more lines to read
                if (line == null)
                {
                    break;
                }

                if (!line.StartsWith("!"))
                {
                    lines.Add(line);
                    width = Math.Max(width, line.Length);

                }
            }
            height = lines.Size();

            for (int j = 0; j < 12; j++)
            {
                string line = (string) lines.Get(j);
                for (int i = 0; i < width; i++)
                {

                    if (i < line.Length)
                    {
                        char ch = line[i];
                        Tile t = new Tile(i, j, char.GetNumericValue(ch));
                        tilearray.Add(t);
                    }

                }
            }

        }