**
Hi I have an assignment where I have the code in c# but need it now in python. The code should do the exact same thinge (point the pirate to the next pirate) can anyone help me :) I am new to python and would be happy if anyone new how to.
**
Make a class Pirate. Each pirate should have a name and a pointer to another pirate.
Make a linked list with pirate objects. Each pirate should point to the pirate following him in the circle. (It could be useful to start with a dummy pirate). When all pirates have been added the circle should be closed by making the last pirate point to the first.
When the circle is closed choose the initial pirate and the counting number (fixed or random values).
Find and print the pirates walking the plank one by one and to find and print the winner. (How does a pirate know when he or she is the winner ? – in Python, not in real life).
namespace Pirates
{
public class Pirates
{
public string name;
public Pirates nextpirate;
public Pirates(string name)
{
this.name = name;
}
}
}
namespace Pirates
{
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// set up 10 pirates
Pirates dummy = new Pirates("Dummy");
Pirates p = new Pirates("p1");
Pirates previouspirate = p;
//dummu points to p1
dummy.nextpirate = p;
for (int i = 2; i <= 10; i++)
{
p = new Pirates("p" + i);
previouspirate.nextpirate = p;
previouspirate = p;
}
// p10 points to p1
p.nextpirate = dummy.nextpirate;
ListBoxPirates.Items.Add("the Pirates :");
p = dummy.nextpirate;
for (int i = 0; i < 10; i++)
{
ListBoxPirates.Items.Add("Pirates " + p.name + "Pointing at " + p.nextpirate.name);
p = p.nextpirate;
}
ListBoxPirates.Items.Add("");
//Countdown
int startnumber = 3;
int countnumber = 5;
p = dummy.nextpirate;
for(int i = 1; i < startnumber; i++)
{
p = p.nextpirate;
}
ListBoxPirates.Items.Add("Counting to " + countnumber + " starting at " + p.name);
ListBoxPirates.Items.Add("");
//countdown
// finished when a pirate is pointing at himself
while(p != p.nextpirate)
{
for(int i = 1; i < countnumber; i++)
{
previouspirate = p;
p = p.nextpirate;
}
ListBoxPirates.Items.Add(p.name + " Walks the plank");
previouspirate.nextpirate = p.nextpirate;
p = p.nextpirate;
}
ListBoxPirates.Items.Add(p.name + " takes the treassure");
ListBoxPirates.Items.Add("");
}
}
}