Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Curciut problem

Curciut problem

Scheduled Pinned Locked Moved C#
graphicsdatabasehelptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Niklas Ulvinge
    wrote on last edited by
    #1

    I got a hard problem I don't know how to solve... How do I, with the classes in item.cs, make elecrisity go from a battery throu two cords and back to the battery again. I'll implement the ohm's later... How do the cord know when it should flow elecrisity.:confused: item.cs:

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Text;

    namespace NiklasUlvinge.ChipsEater
    {
    abstract class Item
    {
    //var's
    public Item[][] input;
    public int x;
    public int y;

        public abstract Strom Output
        {
            get;
        }
        public abstract Point\[\] Snap
        {
            get;
        }
    
        protected Item(int X, int Y)
        {
            x = X;
            y = Y;
            input = new Item\[1\]\[\];
        }
    
        //abstract funcs
        public abstract void function();
        public abstract void draw(Graphics g);
        //funcs
        public void addBothInput(int index, int fromIndex, Item Input)
        {
            Input.addInput(fromIndex, this);
    
            this.addInput(index, Input);
        }
        private void addInput(int index, Item Input)
        {
            index = input.Length & index;
    
            Item\[\] inp = input\[index\];
    
            Item\[\] titem;
    
            if (inp == null)
            {
                titem = new Item\[1\];
            }
            else
                titem = new Item\[inp.Length\];
    
            for (int i = 0; i < titem.Length - 1; i++)
            {
                titem\[i\] = inp\[i\];
            }
            titem\[titem.Length - 1\] = Input;
            input\[index\] = titem;
        }
        public Strom combinedInput(int index)
        {
            Strom r = 0;
            if (input\[index\] == null)
                return 0;
            else
            {
                for (int i = 0; i < input\[index\].Length; i++)
                {
                    r += input\[index\]\[i\].Output\[j\];
                }
                return r;
            }
        }
    
        //const
        protected Brush surf = Brushes.LightGray;
        protected Pen side = Pens.DarkGray;
        protected Pen loff = Pens.Black;
        protected Pen lon = Pens.Red;
    }
    
    class Null : Item
    {
        public override Strom Output
        {
            get
            {
            }
        }
        public override Point\[\] Snap
        {
            get
            {
                return n
    
    R 1 Reply Last reply
    0
    • N Niklas Ulvinge

      I got a hard problem I don't know how to solve... How do I, with the classes in item.cs, make elecrisity go from a battery throu two cords and back to the battery again. I'll implement the ohm's later... How do the cord know when it should flow elecrisity.:confused: item.cs:

      using System;
      using System.Collections.Generic;
      using System.Drawing;
      using System.Text;

      namespace NiklasUlvinge.ChipsEater
      {
      abstract class Item
      {
      //var's
      public Item[][] input;
      public int x;
      public int y;

          public abstract Strom Output
          {
              get;
          }
          public abstract Point\[\] Snap
          {
              get;
          }
      
          protected Item(int X, int Y)
          {
              x = X;
              y = Y;
              input = new Item\[1\]\[\];
          }
      
          //abstract funcs
          public abstract void function();
          public abstract void draw(Graphics g);
          //funcs
          public void addBothInput(int index, int fromIndex, Item Input)
          {
              Input.addInput(fromIndex, this);
      
              this.addInput(index, Input);
          }
          private void addInput(int index, Item Input)
          {
              index = input.Length & index;
      
              Item\[\] inp = input\[index\];
      
              Item\[\] titem;
      
              if (inp == null)
              {
                  titem = new Item\[1\];
              }
              else
                  titem = new Item\[inp.Length\];
      
              for (int i = 0; i < titem.Length - 1; i++)
              {
                  titem\[i\] = inp\[i\];
              }
              titem\[titem.Length - 1\] = Input;
              input\[index\] = titem;
          }
          public Strom combinedInput(int index)
          {
              Strom r = 0;
              if (input\[index\] == null)
                  return 0;
              else
              {
                  for (int i = 0; i < input\[index\].Length; i++)
                  {
                      r += input\[index\]\[i\].Output\[j\];
                  }
                  return r;
              }
          }
      
          //const
          protected Brush surf = Brushes.LightGray;
          protected Pen side = Pens.DarkGray;
          protected Pen loff = Pens.Black;
          protected Pen lon = Pens.Red;
      }
      
      class Null : Item
      {
          public override Strom Output
          {
              get
              {
              }
          }
          public override Point\[\] Snap
          {
              get
              {
                  return n
      
      R Offline
      R Offline
      rudy net
      wrote on last edited by
      #2

      I could not compile your code because type "Strom" is not defined. Can you also provide this as well?

      N 1 Reply Last reply
      0
      • R rudy net

        I could not compile your code because type "Strom" is not defined. Can you also provide this as well?

        N Offline
        N Offline
        Niklas Ulvinge
        wrote on last edited by
        #3

        Form1.Designer.cs:

        namespace NiklasUlvinge.ChipsEater
        {
        partial class Form1
        {
        /// /// Required designer variable.
        ///
        private System.ComponentModel.IContainer components = null;

            /// /// Clean up any resources being used.
            /// 
            /// true if managed resources should be disposed; otherwise, false.
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
        
            #region Windows Form Designer generated code
        
            /// /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// 
            private void InitializeComponent()
            {
                System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Cord");
                System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Transistor");
                System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Battery");
                System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("lowest", new System.Windows.Forms.TreeNode\[\] {
                treeNode1,
                treeNode2,
                treeNode3});
                this.menuStrip1 = new System.Windows.Forms.MenuStrip();
                this.toolStrip1 = new System.Windows.Forms.ToolStrip();
                this.splitContainer1 = new System.Windows.Forms.SplitContainer();
                this.treeItems = new System.Windows.Forms.TreeView();
                this.PB = new System.Windows.Forms.PictureBox();
                this.splitContainer1.Panel1.SuspendLayout();
                this.splitContainer1.Panel2.SuspendLayout();
                this.splitContainer1.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this.PB)).BeginInit();
                this.SuspendLayout();
                // 
                // menuStrip1
                // 
                this.menuStrip1.Location = new System.Drawing.Point(0, 0);
                this.menuStrip1.Name = "menuStrip1";
                this.menuStrip1.Size = new System.Drawing.Size(608, 24);
                this.menuStrip1.TabIndex = 0;
                this.menuStrip1.Text = "menuStrip1";
                // 
                // toolStrip1
                // 
                this.toolStri
        
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups