本文整理汇总了C#中model类的典型用法代码示例。如果您正苦于以下问题:C# model类的具体用法?C# model怎么用?C# model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
model类属于命名空间,在下文中一共展示了model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoHit
public bool DoHit(model.Player a_dealer)
{
int[] cardScores = a_dealer.getCardScoreArray();
total = 0;
if (a_dealer.CalcScore() < 17)
{
return true;
}
if (a_dealer.CalcScore() == 17){
foreach (Card c in a_dealer.GetHand())
{
if (c.GetValue() != Card.Value.Ace)
{
total += cardScores[(int)c.GetValue()];
}
}
//if this is true a soft 17 is active.
if (total <= 6)
{
return true;
}
}
return false;
}
示例2: PlayGame
public PlayGame(model.Game a_game, view.IView a_view)
{
m_game = a_game;
m_view = a_view;
m_view.DisplayWelcomeMessage();
m_game.Subsribe(this);
}
示例3: Play
public bool Play(model.Game a_game, view.IView a_view)
{
//Initialize fields
m_view = a_view;
m_game = a_game;
a_view.DisplayWelcomeMessage();
a_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
a_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
if (a_game.IsGameOver())
{
a_view.DisplayGameOver(a_game.IsDealerWinner());
}
view.Input input = a_view.GetInput();
if (input == view.Input.Play)
{
a_game.NewGame();
}
else if (input == view.Input.Hit)
{
a_game.Hit();
}
else if (input == view.Input.Stand)
{
a_game.Stand();
}
return input != view.Input.Quit;
}
示例4: PlayGame
public PlayGame(model.Game A_game,
view.IView A_view)
{
a_game = A_game;
a_view = A_view;
a_game.addSub(this);
}
示例5: BoatMenu
public int BoatMenu(model.Boat a_boat)
{
Console.Clear();
Console.WriteLine("");
Console.WriteLine("-----Boat specifics-----");
Console.WriteLine("Type: {0}", a_boat.GetType());
Console.WriteLine("Length: {0}", a_boat.GetLength());
Console.WriteLine("");
Console.WriteLine("---------------");
Console.WriteLine("");
Console.WriteLine("(D) to Delete boat (U) to Update boat");
ConsoleKeyInfo input = Console.ReadKey();
if (input.Key == ConsoleKey.D)
{
return 1;
}
else if (input.Key == ConsoleKey.U)
{
return 2;
}
else return 0; //returnera nåt annat
}
示例6: DrawCard
public void DrawCard(model.Card card)
{
m_view.DisplayWelcomeMessage();
m_view.DisplayDealerHand(m_game.GetDealerHand(), m_game.GetDealerScore());
m_view.DisplayPlayerHand(m_game.GetPlayerHand(), m_game.GetPlayerScore());
Thread.Sleep(750);
}
示例7: PlayGame
public PlayGame(model.Game a_game, view.IView a_view)
{
this.a_game = a_game;
this.m_view = a_view;
a_game.AddSubscriber(this);
}
示例8: DoHit
public bool DoHit(model.Player a_dealer)
{
int score = a_dealer.CalcScore();
if (score < g_hitLimit)
{
return true;
}
if (score == g_hitLimit)
{
foreach (Card c in a_dealer.GetHand())
{
//If Ace is in the hand, checks if score without Ace is 6
if ((c.GetValue() == Card.Value.Ace) && (score - 11 == 6))
{
score -= 10;
}
}
return score < g_hitLimit;
}
return false;
}
示例9: DoHit
public bool DoHit(model.Player a_dealer)
{
int[] cardScores = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
var score = 0;
var cards = a_dealer.GetHand();
var numberOfAces = 0;
foreach (var c in cards)
{
if (c.GetValue() != Card.Value.Hidden)
{
score += cardScores[(int)c.GetValue()];
if (c.GetValue() == Card.Value.Ace)
{
numberOfAces++;
}
}
}
while ((score == g_hitLimit || score > 21) && numberOfAces > 0)
{
numberOfAces--;
score -= 10;
}
return score < g_hitLimit;
}
示例10: AddBoat
/// <summary>
/// Add a boat menu
/// </summary>
/// <param name="a_member">model.Member, the member who owns the new boat</param>
private void AddBoat(model.Member a_member)
{
m_console.AddBoat(a_member);
for (int i = 0; i < (int)model.Boat.Type.Count; i += 1)
{
string message = string.Format("{0}: {1}", i, (model.Boat.Type)i);
m_console.WriteMessage(message);
}
int type;
while (true)
{
m_console.WriteMessage("Type: ");
bool isNumeric = int.TryParse(m_console.ReadResponse(), out type);
if (isNumeric && type >= 0 && type < (int)model.Boat.Type.Count)
{
break;
}
m_console.WriteMessage("Invalid type, type must be a number choosen from the list above");
}
double length;
while (true)
{
m_console.WriteMessage("Length: ");
bool isDouble = double.TryParse(m_console.ReadResponse(), out length);
if (isDouble && length > 0)
{
break;
}
m_console.WriteMessage("Invalid length. Length must be of the format XX or XX,XX");
}
a_member.GetBoatList().AddBoat((model.Boat.Type)type, length);
m_console.SetCurrentMenu(view.Console.CurrentMenu.Member);
GoToCurrentMenu(a_member);
}
示例11: DoHit
public bool DoHit(model.Player a_dealer)
{
var cards = a_dealer.GetHand();
// Check if limit has reached....
if (a_dealer.CalcScore() == g_hitLimit)
{
foreach (var card in cards)
{
// Must hit if ace in hand. Because score IS 17!
//Ace turns into 1 score instead
if (card.GetValue() == Card.Value.Ace)
{
return true;
}
}
}
// No special circumstances....
if (a_dealer.CalcScore() < g_hitLimit)
{
return true;
}
else
{
return false;
}
}
示例12: PlayGame
public PlayGame(model.Game g, view.IView v)
{
a_game = g;
a_view = v;
a_view.DisplayWelcomeMessage();
a_game.Subscribe(this);
}
示例13: SensorDataUpdated
public void SensorDataUpdated(model.SensorData data)
{
lock (_lock)
{
List<TcpClient> clientsToDelete = new List<TcpClient>();
foreach (TcpClient client in _clients)
{
try
{
NetworkStream stream = client.GetStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, data);
}
catch (Exception)
{
clientsToDelete.Add(client);
}
}
foreach (TcpClient c in clientsToDelete)
{
_clients.Remove(c);
}
}
}
示例14: AddBoat
// Which member to add the boat to
// Display views, get inputs to create/save boat to a member
private void AddBoat(model.Member member)
{
try
{
_memberView.DisplayMember(member);
model.Boat.BoatType type = _boatView.GetTypeFromUser();
double length = _boatView.GetLengthFromUser();
DateTime registrationDate = _boatView.GetRegistrationDate();
model.Boat boat = new model.Boat(type, length, registrationDate);
member.AddBoat(boat);
_list.SaveMemberList();
DoMemberView(member);
}
catch (Exception ex)
{
_memberView.DisplayMember(member);
_boatView.DisplayErrorMessage(ex.Message);
if (_boatView.DoesUserWantsToQuit() == true)
{
DoMemberView(member);
}
else
{
AddBoat(member);
}
}
}
示例15: Play
public bool Play(model.Game a_game)
{
m_view.DisplayWelcomeMessage();
m_view.DisplayDealerHand(a_game.GetDealerHand(), a_game.GetDealerScore());
m_view.DisplayPlayerHand(a_game.GetPlayerHand(), a_game.GetPlayerScore());
if (a_game.IsGameOver())
{
m_view.DisplayGameOver(a_game.IsDealerWinner());
}
switch((view.Choices)m_view.GetInput())
{
case view.Choices.Play:
a_game.NewGame();
break;
case view.Choices.Hit:
a_game.Hit();
break;
case view.Choices.Stand:
a_game.Stand();
break;
case view.Choices.Quit:
return false;
default:
break;
}
return true;
}