Curciut problem
-
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
-
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
-
I could not compile your code because type "Strom" is not defined. Can you also provide this as well?
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