advanced programming c# lecture 1...

37
Advanced Programming Advanced Programming C# C# Lecture 1 dr inż. Małgorzata Janik [email protected] Winter Semester 2017/2018

Upload: dinhdien

Post on 27-Feb-2019

229 views

Category:

Documents


0 download

TRANSCRIPT

Advanced ProgrammingAdvanced ProgrammingC#C#

Lecture 1

dr inż. Małgorzata [email protected]

Winter Semester 2017/2018

2 / 26C# 2017, Lecture 1

Organizational issues● Lecture + laboratories + project:

– dr inż. Małgorzata JanikZakład Fizyki Jądrowejpok. 117D, Gmach Fizyki

[email protected]

● Time:– Monday, 12:00 – 14:00

● Webpage:– www.if.pw.edu.pl/~majanik/wiki

● Office hours, 117D GF: – Monday, 10:00 – 11:00

– Wednesday 15:00-16:00

3 / 26C# 2017, Lecture 1

Organizational issues● Final grades:

– Laboratories: 60% of the grade

– Project: 40% of the grade

● Laboratories:– 14 classes: 1 instructional, 10 graded, 3 project-related

– used software: Visual Studio Community

– classes duration: 90 minutes (no break)

● Projects:– Project presentation on 6th, 10th and 14th classes

4 / 26C# 2017, Lecture 1

Conditions to pass the classes (1)● Laboratories:

– 10 classes of diversified level (0-6 pkt each)

– during classes you can use any printed materials, your own programs, as well as resources available in the Internet*

– program can be graded at any point in time during classes

– program finished at home: up to +3 pkt● finished program must be presented in the beginning of next class

*) it is forbidden to use mailboxs, messangers, social networks or programs written by other students, as well as

phones, tablets etc. to communicate with others.

● Absences:– max 2 unjustified absences are allowed (0 pkt)

– in case of justified absence student can finish program at home and show it to tutor during the office hours latest two weeks after return (max 5 pkt)

5 / 26C# 2017, Lecture 1

Conditions to pass the classes (2)● Project:

– grading: 0-40 pkt for the project

– During the semester there will be 2 intermediate stages, when the current status of the project should be presented

– Each intermediate stage: 0-10 pkt

– Final project (should be shown in the last class): 0-20 pkt

– To pass the subject >50% of the points from the project should be acquired (minimal project requirements should be completed)

6 / 26C# 2017, Lecture 1

Project proposals● Simulation of several simple physics experiments

● Simulation of the interaction of the radiation with matter

● Main building path finder: application showing the shortest path between two rooms in the Warsaw University of Technology Main Building

● Network Messenger

● Simple RPG game

● Simple platform game

7 / 26C# 2017, Lecture 1

Project proposals● Simulation of several simple physics experiments

● Simulation of the interaction of the radiation with matter

● Main building path finder: application showing the shortest path between two rooms in the Warsaw University of Technology Main Building

● Network Messenger

● Simple RPG game

● Simple platform game ShooterMovementShootingDeathOpponents AI

8 / 26C# 2017, Lecture 1

Project proposals● Simulation of several simple physics experiments

● Simulation of the interaction of the radiation with matter

● Main building path finder: application showing the shortest path between two rooms in the Warsaw University of Technology Main Building

● Network Messenger

● Simple RPG game

● Simple platform game

MarsMinerTile generationSelling MineralsTown BuildingsButtons, Mouse Support

9 / 26C# 2017, Lecture 1

Project proposals● Simulation of several simple physics experiments

● Simulation of the interaction of the radiation with matter

● Main building path finder: application showing the shortest path between two rooms in the Warsaw University of Technology Main Building

● Network Messenger

● Simple RPG game

● Simple platform game Poruszanie sięStrzelanieŚmierćAI przeciwników

MarsMinerTile generationSelling MineralsTown BuildingsButtons, Mouse Support

10 / 26C# 2017, Lecture 1

Conditions to pass the classes (3)● Grading:

– Maximal number of points: 100● laboratories: 10*6 = 60● project: 2*10+20 = 40

● To pass the subject (% of the total number of points):– >50% - 3 (50,5 pkt. – 60,0 pkt.)

– >60% - 3,5 (60,5 pkt. – 70,0 pkt.)

– >70% - 4 (70,0 pkt. – 80,0 pkt.)

– >80% - 4,5 (80,5 pkt. – 90,0 pkt.)

– >90% - 5 (90,5 pkt. – 100,0 pkt.)

● Warning! To pass the subject you have to deliver the project (>50% points)

11 / 26C# 2017, Lecture 1

Literature• English:

1. Joseph Albahari, Ben Albahari, C# 6.0 in a Nutshell, 2016.

2. Ian Griffiths, Programming C# 5.0, O'Reilly Media, 2012.

• Polish:

1. Joseph Albahari, Ben Albahari, C# 6.0 w pigułce, Helion 2016

2. Ian Griffiths - "C# 5.0. Programowanie", Helion, 2013.

3. Andrew Troelsen - "Język C# 2010 i platforma .NET 4", PWN, 2011.

4. Jon Skeet - "C# od podszewki", Helion, 2012.

5. Jesse Liberty - “Programowanie C#”, Helion 2012

12 / 26C# 2017, Lecture 1

Programme

1. Introduction to the C# programming language and Visual Studio software.2. Principles of C# programming language, basic information on the .NET platform. Windows Forms.3. Classes, inheritance, virtual methods. „Factory” methods.4. Interfaces, instruction foreach, yield iterators.5. Standard library classes (collections, streams and files).6. Delegations, lambda expressions.7. Events, exceptions.8. LINQ technology.

13 / 26C# 2017, Lecture 1

Programme

1. Introduction to the C# programming language and Visual Studio software. Principles of C# programming language. 2. Windows Forms.3. Windows Presentation Foundation (WPF).4. Web Forms: ASP.NET.5. Databases: AOD.NET.6. PROJECT I7. Classes, inheritance, virtual methods.8. Delegations, lambda expressions.9. Events, exceptions.10. PROJECT II11. LINQ technology.12. Multithreading.13. To be decided.14. PROJECT II

Introduction to the C# Introduction to the C# language and Visual Studio language and Visual Studio

software software

15 / 26C# 2017, Lecture 1

C#

● C# (pronounced "C sharp") is a programming language that is designed for building a variety of applications that run on the .NET Framework.

16 / 26C# 2017, Lecture 1

.NET Framework

.NET Framework (pronounced dot net) is a software framework developed by Microsoft.

.NET Framework includes 2 parts:

- a large class library known as Framework Class Library (FCL) and provides language interoperability (each language can use code written in other languages) across several programming languages (C#, C++, F#, Visual Basic, and a few dozen others).

- programs written for .NET Framework execute in a software environment known as Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling.

17 / 26C# 2017, Lecture 1

Why C#?

● Simple and easy to learn

● Curly-brace syntax of C# will be instantly recognizable to anyone familiar with C, C++ or Java → easy for people previously programming in any of those languages

● C# syntax simplifies many of the complexities of C++ and provides powerful features such as nullable value types, enumerations, delegates, lambda expressions and direct memory access, which are not found in Java.

● C# supports generic methods and types, which provide increased type safety and performance, and iterators, which enable implementers of collection classes to define custom iteration behaviors that are simple to use by client code.

● Language-Integrated Query (LINQ) expressions make the strongly-typed query a first-class language construct.

Hands on!Hands on!

First console applicationFirst console application

● Open Visual Studio● File → New → Project● Console Application

(.NET Framework)

19 / 26C# 2017, Lecture 1

Console Application - Printing

namespace ConsoleApplication1{ class Program { static void Main(string[] args) { System.Console.WriteLine("Hello World!");

// Keep the console window open in debug mode. System.Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); } }}

20 / 26C# 2017, Lecture 1

Console Application - Variables

namespace ConsoleApplication1{ class Program { static void Main(string[] args) { System.Console.WriteLine("Hello World!");

int a = 10; string b = "label"; System.Console.WriteLine("Variables: {0} {1}", a, b);

var c = "label2"; // var d; // NOT POSSIBLE // Keep the console window open in debug mode. System.Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); } }}

21 / 26C# 2017, Lecture 1

Console Application - Task

namespace ConsoleApplication1{ class Program { static void Main(string[] args) { System.Console.WriteLine("Hello World!");

int a = 10; string b = "label"; System.Console.WriteLine("Variables: {0} {1}", a, b);

var c = "label2";

// TASK // Print: type of c, length of c and value of c

// Keep the console window open in debug mode. System.Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); } }}

Type “c.” and wait for the list of possible methods and properties appear.

Browse through them and try to find the ones requested.

22 / 26C# 2017, Lecture 1

Sign in into Visual Studio….

23 / 26C# 2017, Lecture 1

Sign in into Visual Studio….

To samo konto, co poczta politechniczna:

https://portal.office.com

[numer albumu]@[email protected]

24 / 26C# 2017, Lecture 1

Sign in into Visual Studio….

Visual Studio Team Services site:

NazwiskoCsharp2017.visualstudio.com

Visual Studio Team ServicesVisual Studio Team Services

● Open in webbrowserNazwiskoCsharp2017.visualstudio.com

→ New project

- Lab1WindowsFormsProject

- Git

- Agile

26 / 26C# 2017, Lecture 1

Agile software developement

Agile is a term used to describe a general approach to software development.

All agile methods, emphasize teamwork, frequent deliveries of working software, close customer collaboration, and the ability to respond quickly to change.

27 / 26C# 2017, Lecture 1

Visual Studio Team Services: Work

WORK tab: Board

- It's new (New)

- I'm working on it (Active)

- I think I've finished / fixed it (Resolved)

- Yes, it's finished / fixed, never look at it again (Closed)

Create three tasks:

(1) „Learn basic features of VS Team Services”

(2) „Create new project and synchronize it with repository”

(3) “Write demo program in Windows Forms.”

Move „Learn basic features of VS Team Services” to Active.

28 / 26C# 2017, Lecture 1

Dashboards: other functionalities of VSTS

Team Members

→ Invite a friend

Dashboad

→ Add Team Room

Rooms

→ See rooms

→ Create events

„Learn basic features of VS Team Services” → Resolved

“Create new project and synchronize it with repository” → Active

29 / 26C# 2017, Lecture 1

Create new project and synchronize it with repository

30 / 26C# 2017, Lecture 1

Create new project and synchronize it with repository

New…

Project

Windows Forms Application

31 / 26C# 2017, Lecture 1

Planned application

Initial window:

32 / 26C# 2017, Lecture 1

Planned application

Initial window: Used functionalities:

33 / 26C# 2017, Lecture 1

Create new project and synchronize it with repository

34 / 26C# 2017, Lecture 1

Properties and Events

Properties Events

35 / 26C# 2017, Lecture 1

Build your application

Used functionalities:

Remember to:- give readable names to all controls- commit changes after each part

Names:- Always change default names!- Each team can have its own naming convention.- Common thing: names are readable!

This classes:- Always keep the control name

+ readable part.e.g. formMainWindow

labelHelloWorld

36 / 26C# 2017, Lecture 1

Additional links

Visual Studio Team Services Agile youtube tutorials:https://www.youtube.com/watch?v=Vj7DmdO4-Fghttps://www.youtube.com/watch?v=fTGv3BAgCiM

GIT:https://docs.microsoft.com/en-us/vsts/git/share-your-code-in-git-vs-2017

THE ENDTHE END