- 1
- 2
public ArgumentException (string? message, string? paramName);
public ArgumentNullException (string? paramName, string? message);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
public ArgumentException (string? message, string? paramName);
public ArgumentNullException (string? paramName, string? message);
https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.-ctor?view=net-7.0#system-argumentexception-ctor(system-string-system-string)
https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.-ctor?view=net-7.0#system-argumentnullexception-ctor(system-string-system-string)
0
using System;
using System.Linq;
namespace TheBestGenerator
{
class Symbols
{
protected const string Letters = "abcdefghijklmnopqrstuvwxyz";
protected const string Numbers = "0123456789";
protected const string DefaultSpecialSymbols = @"!#$%&*@\";
protected static Random rand = new Random();
}
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Введите длину пароля:");
int Len = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Generator.Password(Len));
}
}
}
class Generator: Symbols
{
static char[] Array_()
{
return (Numbers+Letters+Letters.ToUpper()+DefaultSpecialSymbols).ToCharArray();
}
static char[] Password_Symbols()
{
return Array_().OrderBy(Symbol => rand.Next()).ToArray();
}
public static string Password(int Len )
{
char[] password = Password_Symbols();
Array.Resize(ref password, Len);
return (string.Join("", password));
}
}
}
Генератор паролей. Говнокод с наследованием. Почти ничего не понимаю в нем, но "прогу" с ним написал.
0
public class Archvile:Actor{public Archvile(){Health=700;Radius=20;Height=56;Mass=500;Speed=15;PainChance=10;Monster=true;MaxTargetRange=896;SetFlag(Flags.QUICKTORETALIATE,true);SetFlag(Flags.FLOORCLIP,true);SetFlag(Flags.NOTARGET,true);SeeSound="vile/sight";PainSound="vile/pain";DeathSound="vile/death";ActiveSound="vile/active";MeleeSound="vile/stop";Obituary="$OB_VILE";Tag="$FN_ARCH";}
public override void BeginPlay(){base.BeginPlay();SetState("Spawn");}
void Spawn(){SetState("See");}
void See(){A_Chase();}
void Missile(){A_VileStart();A_FaceTarget();A_VileTarget();A_FaceTarget();A_VileAttack();Delay(20);SetState("See");}
void Heal(){Delay(10);SetState("See");}
void Pain(){A_Pain();SetState("See");}
void Death(){A_Scream();A_NoBlocking();Delay(7);SetState("Death 1");}
void Death1(){Delay(7);SetState("Death 2");}
void Death2(){Delay(7);SetState("Death 3");}
void Death3(){Delay(7);SetState("Death 4");}
void Death4(){Delay(7);SetState("Death 5");}
void Death5(){Delay(7);SetState("Death 6");}
void Death6(){Delay(7);SetState("Death 7");}
void Death7(){Delay(1);Destroy();}
void A_VileStart(){StartSound("vile/start",CHAN_VOICE);}
void A_VileTarget(){if(target!=null){A_FaceTarget();Actor fog=Spawn<Actor>("ArchvileFire",target.Pos,SpawnFlags.ALLOW_REPLACE);if(fog!=null){tracer=fog;fog.target=self;fog.tracer=self.target;fog.A_Fire(0);}}}
void A_VileAttack(){Actor targ=target;if(targ!=null){A_FaceTarget();if(!CheckSight(targ,0))return;StartSound("vile/stop",CHAN_WEAPON);int newdam=targ.DamageMobj(self,self,20,DamageType.none);if(newdam>0)targ.TraceBleed(newdam,self);Actor fire=tracer;if(fire!=null){fire.SetOrigin(targ.Vec3Angle(-24.0,angle,0),true);fire.A_Explode(70,70,ExplosionFlags.XF_NOSPLASH,false,0,0,0,"BulletPuff",DamageType.Fire);}
if(!targ.bDontThrust){targ.Vel.z=1000.0*thrust/Math.Max(1,targ.Mass);}}}
void A_StartFire(){StartSound("vile/firestrt",CHAN_BODY);A_Fire();}
void A_Fire(){Actor dest=tracer;if(dest==null||target==null)return;if(!target.CheckSight(dest,0))return;SetOrigin(dest.Vec3Angle(24,dest.angle,0),true);}
void A_FireCrackle(){StartSound("vile/firecrkl",CHAN_BODY);A_Fire();}}
public static class ActorExtensions{public static void A_VileStart(this Actor self){self.StartSound("vile/start",CHAN_VOICE);}
public static void A_VileTarget(this Actor self,string fire="ArchvileFire"){if(self.target!=null){self.A_FaceTarget();Actor fog=self.Spawn<Actor>(fire,self.target.Pos,SpawnFlags.ALLOW_REPLACE);if(fog!=null){self.tracer=fog;fog.target=self;fog.tracer=self.target;fog.A_Fire(0);}}}
public static void A_VileAttack(this Actor self,string snd="vile/stop",int initialdmg=20,int blastdmg=70,int blastradius=70,double thrust=1.0,string damagetype="Fire",int flags=0){Actor targ=self.target;if(targ!=null){self.A_FaceTarget();if(!self.CheckSight(targ,0))return;self.StartSound(snd,CHAN_WEAPON);int newdam=targ.DamageMobj(self,self,initialdmg,(flags
Арчвайл из ZDooM на C#
0
protected override Detail GetDetailPage(
aggregate aggregate,
int cashbackRate,
BannerResponse bannerInfo,
List<MediaShortResponse> mediaInfo,
EntityFavourites likeCountInfo,
List<FavouriteEntity> likeInfo)
{
var announcementDetail = new Detail
(
aggregate.Details.Id,
aggregate.Details.Alias,
aggregate.Details.Title,
aggregate.Details.Description,
aggregate.Details.DescriptionShortcut,
aggregate.Details.Age,
aggregate.ExtendedDetails.DataSourceId,
aggregate.ExtendedDetails.DataSourceItemId,
cashbackRate,
null,
aggregate.ExtendedDetails.LastEventDateTime,
aggregate.ExtendedDetails.EventClosestDateTime,
aggregate.ExtendedDetails.Url,
aggregate.ExtendedDetails.Category != null
? new AnnouncementCategory(aggregate.ExtendedDetails.Category.Id,
aggregate.ExtendedDetails.Category.Title,
aggregate.ExtendedDetails.Category.Url)
: null,
aggregate.ExtendedDetails.Tags?.Select(ss =>
new Tag(ss.Title, HttpUtility.UrlPathEncode(ss.Url))
).ToList(),
aggregate.Details.Privileges?.Select(ss => new Privilege()
{
Description = ss.Description,
Id = ss.Id,
ImageUrl = ss.ImageUrl.ToString(),
Title = ss.Title
}).ToList(),
mediaInfo.Select(m => new Media
{
Type = m.Type,
Url = m.Url
}).ToList(),
aggregate.ExtendedDetails.EventMinPrice,
likeInfo.FirstOrDefault(x => x.EntityId == aggregate.Details.Id)?.IsSet ?? false,
likeCountInfo?.TotalCount,
aggregate.ExtendedDetails.Promotext,
bannerInfo != null ? new Banner { Url = bannerInfo.Url, ImageUrl = bannerInfo.ImageUrl } : null,
aggregate.Details.Venue != null
? new ShortVenue(aggregate.Details.Venue.Id,
aggregate.Details.Venue.Title,
aggregate.Details.Venue.Url.Replace(_liveBaseAddress, ""),
aggregate.Details.Venue.Address)
: null,
(AnnouncementStatus)aggregate.Details.Status,
aggregate.ExtendedDetails.PremiumRule,
aggregate.Details.HasPrivilegeEnabled,
);
return announcementDetail;
}
0
class StargateSimulator
{
static bool shieldEnabled = false;
static void Main()
{
Console.WriteLine("Stargate Simulator");
Console.WriteLine("------------------");
// Check for zero point module
Console.Write("Zero Point Module detected. Proceed with simulation? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Simulation cancelled.");
return;
}
// Enable shield
Console.Write("Enable gate shield? (y/n) ");
response = Console.ReadLine();
if (response.ToLower() == "y")
{
EnableShield();
}
// Enter gate address
Console.Write("Enter gate address: ");
string address = Console.ReadLine();
if (address.Length != 6 && address.Length != 8)
{
Console.WriteLine("Invalid address length.");
return;
}
// Dial gate
Dial(address);
Console.WriteLine("Simulation complete.");
}
static void Dial(string address)
{
// Check for valid address
if (address.Length != 6 && address.Length != 8)
{
Console.WriteLine("Invalid address length.");
return;
}
// Check for energy source
Console.Write("Energy source detected. Proceed with dialing? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Dialing cancelled.");
return;
}
// Dial gate
Console.WriteLine("Dialing gate...");
if (shieldEnabled)
{
Console.WriteLine("Gate shield is active.");
}
Console.WriteLine("Chevron 1 encoded.");
Console.WriteLine("Chevron 2 encoded.");
Console.WriteLine("Chevron 3 encoded.");
Console.WriteLine("Chevron 4 encoded.");
Console.WriteLine("Chevron 5 encoded.");
Console.WriteLine("Chevron 6 encoded.");
if (address.Length == 8)
{
Console.WriteLine("Chevron 7 encoded.");
Console.WriteLine("Gate engaged.");
}
else
{
Console.WriteLine("Gate engaged.");
}
}
static void EnableShield()
{
// Check for available power
Console.Write("Power levels stable. Activate gate shield? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Shield activation cancelled.");
return;
}
// Activate shield
Console.WriteLine("Shield activated.");
shieldEnabled = true;
}
}
Симулятор наборного устройства звездных врат.
P.S. За Канон-френдли не отвечаю, т.к. фанат серии но любитель немножко поизвращаться над ЛОРом...
0
namespace TimeMachineSimulator
{
class Program
{
static void Main()
{
Console.WriteLine("Welcome to the Time Machine Simulator!");
TimeMachine machine = new();
while (true)
{
Console.WriteLine("What would you like to do?");
Console.WriteLine("1. Travel in time");
Console.WriteLine("2. Show current time");
Console.WriteLine("3. Show travel history");
Console.WriteLine("4. Exit");
string input = Console.ReadLine();
Console.WriteLine();
switch (input)
{
case "1":
Console.Write("Enter the number of years to travel: ");
int years = int.Parse(Console.ReadLine());
try
{
machine.Travel(years);
Console.WriteLine("Travel successful.");
}
catch (TimeMachineException e)
{
Console.WriteLine(e.Message);
}
break;
case "2":
Console.WriteLine("Current time: " + machine.GetCurrentTime());
break;
case "3":
List<DateTime> history = machine.GetTravelHistory();
Console.WriteLine("Travel history:");
foreach (DateTime time in history)
{
Console.WriteLine(time);
}
Console.WriteLine();
break;
case "4":
Console.WriteLine("Thank you for using the Time Machine Simulator! Press any key to exit...");
Console.ReadKey();
return;
default:
Console.WriteLine("Invalid input. Please try again.");
break;
}
}
}
}
public class TimeMachineException : Exception { public TimeMachineException(string message) : base(message){}}
public class TimeMachine
{
private DateTime currentTime;
private readonly List<DateTime> travelHistory;
public TimeMachine()
{
this.currentTime = DateTime.Now;
this.travelHistory = new List<DateTime>();
}
public void Travel(int years)
{
DateTime futureTime = this.currentTime.AddYears(years);
if (futureTime > DateTime.Now)
{
throw new TimeMachineException("Cannot travel to the future!");
}
this.currentTime = futureTime;
this.travelHistory.Add(futureTime);
}
public DateTime GetCurrentTime()
{
return this.currentTime;
}
public List<DateTime> GetTravelHistory()
{
return this.travelHistory;
}
}
}
Пространственно-временной квантовый реинтегратор. Правда в будущее не умеет отправлять, но используя свойства реверсивной энтропии может отправить куда угодно только в прошлое!
0
namespace NardeGame { public class NardeGame { static void Main() { Console.WriteLine("Welcome to Narde Game!"); NardeGame game = new(); game.Play(); Console.WriteLine("Thank you for playing Narde Game! Press any key to exit..."); Console.ReadKey(); } private readonly Player player1; private readonly Player player2; private readonly Board board; public NardeGame() { player1 = new Player("Armen"); player2 = new Player("Suren"); board = new Board(); } public void Play() { while (!board.IsGameOver()) { Player currentPlayer = board.GetTurn() == Turn.WHITE ? player1 : player2; Console.WriteLine("It's " + currentPlayer.GetName() + "'s turn."); Console.WriteLine(board); int from, to; do { Console.Write("Enter the starting point of your move: "); from = int.Parse(Console.ReadLine()); Console.Write("Enter the ending point of your move: "); to = int.Parse(Console.ReadLine()); } while (!Board.IsValidMove(from, to, currentPlayer.GetColor())); Board.MakeMove(from, to); board.NextTurn(); } Console.WriteLine("Game over."); Console.WriteLine(board); Console.WriteLine(board.GetWinner().GetName() + " won!"); } } public enum Color { WHITE, BLACK } public enum Turn { WHITE, BLACK } public class Player { private readonly string name; private readonly Color color; public Player(string name) { this.name = name; color = name == "Armen" ? Color.WHITE : Color.BLACK; } public string GetName() { return name; } public Color GetColor() { return color; } } public class Board { private readonly int[] points; private Turn turn; public Board() { points = new int[24] { 2, 0, 0, 0, 0, -5, 0, 3, 0, 0, 0, -5, 5, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, -2 }; turn = Turn.WHITE; } public bool IsGameOver() { int whiteCount = 0; int blackCount = 0; for (int i = 0; i < 24; i++) { if (points[i] > 0) { whiteCount += points[i]; } else if (points[i] < 0) { blackCount -= points[i]; } } return whiteCount == 0 || blackCount == 0; } public Player? GetWinner() { int whiteCount = 0; int blackCount = 0; for (int i = 0; i < 24; i++) { if (points[i] > 0) { whiteCount += points[i]; } else if (points[i] < 0) { blackCount -= points[i]; } } if (whiteCount > blackCount) { return new Player("Armen"); } else if (blackCount > whiteCount) { return new Player("Suren"); } else { return null; } } public Turn GetTurn() { return turn; } public void NextTurn() { turn = turn == Turn.WHITE ? Turn.BLACK : Turn.WHITE; } public static bool IsValidMove(int from, int to, Color color) { return true; } public static void MakeMove(int from, int to) { } public override string ToString() { string output = ""; for (int i = 0; i < 24; i++) { output += points[i] + " "; } return output.TrimEnd(); } } }
Армяне играют в однострочные нарды... :)
0
namespace ParticleAccelSim
{
public class Particle
{
public double X { get; set; } // координата частицы по оси x
public double Y { get; set; } // координата частицы по оси y
public double VX { get; set; } // скорость частицы по оси x
public double VY { get; set; } // скорость частицы по оси y
public double Mass { get; set; } // масса частицы
public double Charge { get; set; } // заряд частицы
public Particle(double x, double y, double vx, double vy, double mass, double charge)
{
X = x;
Y = y;
VX = vx;
VY = vy;
Mass = mass;
Charge = charge;
}
}
public class ParticleAccelerator
{
private List<Particle> particles = new List<Particle>(); // список всех частиц
private double timeStep = 0.01; // размер шага при моделировании
public void AddParticle(Particle p)
{
particles.Add(p);
}
public void RunSimulation(int numSteps)
{
for (int i = 0; i < numSteps; i++)
{
foreach (Particle p in particles)
{
// вычисляем силы, действующие на частицу
double ax = 0;
double ay = 0;
foreach (Particle other in particles)
{
if (other != p)
{
double dx = other.X - p.X;
double dy = other.Y - p.Y;
double r = Math.Sqrt(dx * dx + dy * dy);
double f = (p.Charge * other.Charge) / (r * r); // закон Кулона
ax += f * dx / r;
ay += f * dy / r;
}
}
// вычисляем новое положение и скорость частицы
p.VX += ax * timeStep / p.Mass;
p.VY += ay * timeStep / p.Mass;
p.X += p.VX * timeStep;
p.Y += p.VY * timeStep;
}
}
}
}
}
Исходный код симулятора ускорителя частиц, например "Большой адронный коллайдер". Просьба не запускать этот код, т.к. я уже пару дней назад запустил, а сегодня уже не могу понять правильно говорить "Возможность этого резиста крайне мала" или "Вероятность этого резиста крайне мала"... ТАК ЧТО БУДЬТЕ ОСТОРОЖНЫ! Можно сломать нашу реальность!
0
/// <summary>
/// Converts an object to null. Returns null.
/// </summary>
public static object ToNull(this object value)
{
return null;
}
Индийский extension
0
Eb!
Eb!
Eb!
Хрюк-хрюк-хрюк-хрюк