NPRG38 zkouska 3.6.2010

Abriel! at 2010-06-03 16:17:55

Zdravim, tak zkouska uz je za nama a otazky byly vazne zajimave :-)

class Program{static void Main(string[] args){var n = new MyEnumerable();var list = from x in n where x > 1 select x;foreach (var i in list){Console.Write("g({0}) ", i);} }}
public class MyEnumerable : IEnumerable<int>{public IEnumerator<int> GetEnumerator(){Console.Write("1 ");yield return 1;Console.Write("2 ");yield return 2;Console.Write("3 ");yield return 3;}
IEnumerator IEnumerable.GetEnumerator(){return GetEnumerator();}}

Co bude na vystupu?

	<Window x:Class="WPFZkouska.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <StackPanel><TextBlock Margin="10" Text="neco1" /><TextBlock Margin="10" Text="neco2" /></StackPanel></Window>

Do prazdneho mista zadejte kod, tak aby oba TextBlocky mely cervene pozadi.

  1. (Tady se omlouvam, ale ten kod neni uplne presny)

     <Window x:Class="WPFZkouska.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <StackPanel><Rectangle x:Name="ctverec" Fill="Red" Width="50" Height="50"><Rectangle.Style><Style><Style.Triggers><Trigger Property="Rectangle.IsMouseOver" Value="true"><Setter Property="Rectangle.Fill" Value="Green" /></Trigger></Style.Triggers></Style></Rectangle.Style></Rectangle></StackPanel></Window>
    

Jakou barvu bude mit ctverec po spusteni programu?
Jakou barvu bude mit ctverec po najeti mysi do ctverce?
Jakou barvu bude mit ctverec pote co mys opusti ctverec?

public class MyClass{int a;

int b;

public int A{get { return a; }set{if (value > 0)throw new ArgumentException();
a = value;}}


public int B{get { return b; }set { b = value; }}}

Do prazdnych mist vyplnte kod, tak aby trida byla serializovatelna pomoci nejakeho formateru a aby pri deserializaci nevznikaly chyby.

  1. CLI/C++
    tu si prilis nepamatuju, tak nekdo doplnte!

_Flavius at 2010-06-03 18:03:32

Good job :-)
Btw., je u jedničky nějaká zvláštní finta, nebo to je prostě 1g(1)2g(2)3g(3)?

_Flavius at 2010-06-03 20:31:22

Tak si odpovím sám (resp. s pomocí Visual Studia), vypíše to "1 2 g(2) 3 g(3)" - nevšiml jsem si, že tam je to filtrování čísel větších než jedna.

Shigi at 2010-06-03 22:29:29

V tej prvej úlohe - v tele foreach-u bol ešte break; ..takže správna odpoveď mala byť 1 2 g(2)