josephworks / csharp Goto Github PK
View Code? Open in Web Editor NEWCSharp Files - Advanced Software Developer
License: GNU Affero General Public License v3.0
CSharp Files - Advanced Software Developer
License: GNU Affero General Public License v3.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp4
{
class SetofDice
{
Dice[] m_dice = new Dice[5];
bool[] m_keep = new bool[5];
int m_numrolls = 0;
public SetofDice()
{
for (int i = 0; i < m_dice.Length; i++)
{
m_dice[i] = new Dice();
}
}
public void Reset()
{
m_numrolls = 0;
for (int i = 0; i < m_keep.Length; i++)
{
m_keep[i] = false;
}
}
public void Keep(int n)
{
m_keep[n] = true;
}
public void Roll()
{
if (m_numrolls == 3)
return;
m_numrolls++;
for (int i = 0; i < 5; i++)
{
if (!m_keep[i])
m_dice[i].Roll();
}
}
public bool threeOfaKind()
{
int[] vals = new int[5];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = m_dice[i].getValue();
}
Array.Sort(vals);
for (int i = 0; i < 3; i++)
{
if (vals[i] == vals[i + 1] &&
vals[i + 1] == vals[i + 2])
{
return true;
}
}
return false;
}
public bool fourOfaKind()
{
int[] vals = new int[5];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = m_dice[i].getValue();
}
Array.Sort(vals);
for (int i = 0; i < 2; i++)
{
if (vals[i] == vals[i + 1] &&
vals[i + 1] == vals[i + 2] &&
vals[i + 2] == vals[i + 3])
{
return true;
}
}
return false;
}
public bool Yahtzee()
{
int[] vals = new int[5];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = m_dice[i].getValue();
}
Array.Sort(vals);
for (int i = 0; i < 1; i++)
{
if (vals[i] == vals[i + 1] &&
vals[i + 1] == vals[i + 2] &&
vals[i + 2] == vals[i + 3] &&
vals[i + 3] == vals[i + 4])
{
return true;
}
}
return false;
}
public bool fullHouse()
{
int[] vals = new int[5];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = m_dice[i].getValue();
}
Array.Sort(vals);
for (int i = 0; i < 1; i++)
{
if (vals[i] == vals[i + 1] &&
vals[i + 1] == vals[i + 2] &&
vals[i + 3] == vals[i + 4] ||
vals[i + 2] == vals[i + 3] &&
vals[i + 3] == vals[i + 4] &&
vals[i] == vals[i + 1])
{
return true;
}
}
return false;
}
public bool largeStraight()
{
int[] vals = new int[5];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = m_dice[i].getValue();
}
Array.Sort(vals);
if (vals[0] == 1 &&
vals[1] == 2 &&
vals[2] == 3 &&
vals[3] == 4 &&
vals[4] == 5 ||
vals[0] == 2 &&
vals[1] == 3 &&
vals[2] == 4 &&
vals[3] == 5 &&
vals[4] == 6)
{
return true;
}
return false;
}
public int getValue(int n)
{
return m_dice[n].getValue();
}
public override string ToString()
{
string retVal = "";
for (int i = 0; i < m_dice.Length; i++)
{
retVal += m_dice[i].getValue() + ", ";
}
return retVal;
}
}
}
while((MessageBox.Show("Do you want another beep",
"State Controlled Loop", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes))
{
Beep();
}
#pragma config(Sensor, in1, lineFolower, sensorLineFollower)
#pragma config(Sensor, in2, potentiometer, sensorPotentiometer)
#pragma config(Sensor, in3, lightSensor, sensorReflection)
#pragma config(Sensor, dgtl1, limitSwitch, sensorDigitalIn)
#pragma config(Sensor, dgtl2, touchsensor, sensorTouch)
#pragma config(Sensor, dgtl3, lowerEncoder, sensorRotation)
#pragma config(Sensor, dgtl4, upperEncoder, sensorRotation)
#pragma config(Sensor, dgtl5, ultrasonicIn, sensorDigitalIn)
#pragma config(Sensor, dgtl6, ultrasonicOut, sensorDigitalOut)
#pragma config(Sensor, dgtl12, greenLed, sensorLEDtoVCC)
#pragma config(Motor, port1, flashlight, tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor, port2, rightMotor, tmotorVex393TurboSpeed_MC29, openLoop, driveRight)
#pragma config(Motor, port3, leftMotor, tmotorVex393TurboSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port8, servoMotor, tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
//task servorun()
//{
// setServo(servoMotor, 95);
// sleep(1000);
// while(true)
// {
// setServo(servoMotor, 127);
// sleep(250);
// setServo(servoMotor, -127);
// }
//}
task main()
{
//while (SensorValue(sensorTouch) == 1)
robotType(none);
//startTask( servorun );
while(true)
{
turnFlashlightOff(flashlight);
turnLEDOff(greenLed);
stopMotor(leftMotor);
stopMotor(rightMotor);
untilTouch(touchsensor);
turnLEDOn(greenLed);
turnFlashlightOn(flashlight, 127);
startMotor(leftMotor, 127);
startMotor(rightMotor, 127);
setServo(servoMotor, 127);
sleep(20);
turnFlashlightOff(flashlight);
turnLEDOff(greenLed);
sleep(20);
setServo(servoMotor, -127);
}
}
Into /Quantum
protected enum Tone
{
REST = 0,
GbelowC = 3196,
A = 3220,
Asharp = 3233,
B = 3247,
C = 3262,
Csharp = 3277,
D = 3294,
Dsharp = 3311,
E = 3330,
F = 3349,
Fsharp = 3370,
G = 3392,
Gsharp = 3415,
//Needs tuning, change 1 at the beginning to change frequency by on khz
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.