NPRG38 zkouska 3.6.2010

Abriel!

NPRG38 zkouska 3.6.2010

Příspěvek od Abriel! »

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

1)

Kód: Vybrat vše

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?

2)

Kód: Vybrat vše

	<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.

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

Kód: Vybrat vše

	<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?

4)

Kód: Vybrat vše



	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.

5) CLI/C++
tu si prilis nepamatuju, tak nekdo doplnte!
_Flavius

Re: NPRG38 zkouska 3.6.2010

Příspěvek od _Flavius »

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

Re: NPRG38 zkouska 3.6.2010

Příspěvek od _Flavius »

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
Matfyz(ák|ačka) level I
Příspěvky: 6
Registrován: 29. 1. 2009 02:12
Typ studia: Informatika Bc.
Kontaktovat uživatele:

Re: NPRG38 zkouska 3.6.2010

Příspěvek od Shigi »

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

Zpět na „NPRG038 Pokročilé programování pro .NET“