SlideShare a Scribd company logo
1 of 46
Download to read offline
DR ATIF SHAHZAD
Computer Applications
in Industrial Engg.-I
IE-322
LECTURE #08
Computer Applications in
Industrial Engg.-I
IE322
…Recap
9/27/2018
Dr.AtifShahzad
What we will see…
9/27/2018
Dr.AtifShahzad
A Random Review
A quick Question
Classes
• Class vs Object:
Examples
• Class vs Object:
Adding a Class to a C#
project
Declaring a Class
Adding a Method to the
Class
Instantiating an object
of a class
Calling a Method of an
object
Complete Example—
class Car
Solution Explorer
Files of the project in
Windows explorer
Example2:
Some built-in classes
A BonusTopic
• Look this example
• Conditional Operator
What is aVisual Studio
Project?
What is aVisual Studio
Solution?
Project & Solution
A Random Review
Dr.AtifShahzad
5
Data types are sets
(ranges) of values that
have similar
characteristics.
A Random Review
Dr.AtifShahzad
6
DataTypes DefaultValue MinimumValue MaximumValue
sbyte 0 -128 127
byte 0 0 255
short 0 -32768 32767
ushort 0 0 65535
int 0 -2147483648 2147483647
uint 0u 0 4294967295
long 0L -9223372036854775808 9223372036854775807
ulong 0u 0 18446744073709551615
float 0.0f ±1.5×10-45 ±3.4×1038
double 0.0d ±5.0×10-324 ±1.7×10308
decimal 0.0m ±1.0×10-28 ±7.9×1028
bool false Two possible values: true and false
char 'u0000' 'u0000' 'uffff'
object null - -
string null - -
A Random Review: Integer types
Dr.AtifShahzad
7
// Declare some variables
byte centuries = 20;
ushort years = 2000;
uint days = 730480;
ulong hours = 17531520;
// Print the result on the console
Console.WriteLine(centuries + " centuries are " + years +
" years, or " + days + " days, or " + hours + " hours.
");
// Console output:
// 20 centuries are 2000 years, or 730480 days, or 17531520
// hours.
ulong maxIntValue = UInt64.MaxValue;
Console.WriteLine(maxIntValue); // 18446744073709551615
A Random Review: Real types
Dr.AtifShahzad
8
// Declare some variables
float floatPI = 3.141592653589793238f;
double doublePI = 3.141592653589793238;
// Print the results on the console
Console.WriteLine("Float PI is: " + floatPI);
Console.WriteLine("Double PI is: " + doublePI);
// Console output:
// Float PI is: 3.141593
// Double PI is: 3.14159265358979
A quick Question
9/27/2018
Dr.AtifShahzad
9
int age = 8;
if ( !(age >= 16) )
{
Console.Write("Your age is less than 16");
}
//What is the OUTPUT?
A quick Question
int age = 8;
if ( !(age >= 16) ) {
Console.Write("Your age is less than 16");
}
// Outputs "Your age is less than 16"
9/27/2018
Dr.AtifShahzad
10
Classes
IE322
Classes
Classes act as templatesfrom which
an instance of an object is created at run time.
9/27/2018
Dr.AtifShahzad
12
Classes
Classes act as templates
from which
an instance of an object is created
at run time.
Classes define the properties of the object
and the methods used to control the
object's behavior.
9/27/2018
Dr.AtifShahzad
13
Class vs Object: Example 1
Dr.AtifShahzad
14
Drawing of House
House
Class vs Object: Example 2
Dr.AtifShahzad
15
Engineering Drawing of a car
Car
Class vs Object: Example 3
Dr.AtifShahzad
16
BankAccountclass
Bank Account of a customer
Class vs Object: Example 4
Dr.AtifShahzad
17
Student class
A particular student
Class vs Object:You examples?
Dr.AtifShahzad
18
Class:
Object:
Attributes:
Methods:
Class vs Object:
Dr.AtifShahzad
19
Class:
Object:
Attributes or States or Properties
these are the characteristics of the object which define it in a
way and describe it in general or in a specific moment
Methods or Behaviors
these are the specific distinctive actions, which can be done by
the object.
Methods:
Adding a Class to a C# project
Dr.AtifShahzad
20
Declaring a Class
Dr.AtifShahzad
21
Let us create a class named as Car
namespace CarApp
{
class Car
{
}
}
Declaring a Class
Dr.AtifShahzad
22
Let us create a class named as Car
namespace CarApp
{
class Car
{
} // end class Car
}//end namespace CarApp
Adding a Method to the Class
Dr.AtifShahzad
23
namespace CarApp
{
class Car
{
public void Start()
{ // A method
Console.WriteLine("Car has been
started");
}
} // end class Car
}//end namespace CarApp
Instantiating an object of a class
Dr.AtifShahzad
24
In the Main method of the Program:
Car MyCar = new Car();
Calling a Method of an object
Dr.AtifShahzad
25
Access or dot (.) operator
MyCar.Start();
Complete Example—class Car
Dr.AtifShahzad
26
Complete Example—class Program
Dr.AtifShahzad
27
Solution Explorer
Dr.AtifShahzad
28
Files of the project inWindows
explorer
9/27/2018
Dr.AtifShahzad
29
Example2:
Dr.AtifShahzad
30
public class Cat
{
// Field name
private string name;
// Field color
private string color;
public string Name
{
// Getter of the property "Name"
get
{
return this.name;
}
// Setter of the property "Name"
set
{
this.name = value;
}
}
public string Color
{
// Getter of the property "Color"
get
{
return this.color;
}
// Setter of the property "Color"
set
{
this.color = value;
}
}
// Default constructor
public Cat()
{
this.name = "Unnamed";
this.color = "gray";
}
// Constructor with parameters
public Cat(string name, string color)
{
this.name = name;
this.color = color;
}
// Method SayMiau
public void SayMiau()
{
Console.WriteLine("Cat {0} said: Miauuuuuu!", name);
}
}
public class Cat
{
// Field name
private string name;
// Field color
private string color;
public string Name
{
// Getter of the property "Name"
get
{
return this.name;
}
// Setter of the property "Name"
set
{
this.name = value;
}
}
public string Color
{
// Getter of the property "Color"
get
{
return this.color;
}
// Setter of the property "Color"
set
{
this.color = value;
}
}
// Default constructor
public Cat()
{
this.name = "Unnamed";
this.color = "gray";
}
// Constructor with parameters
public Cat(string name, string color)
{
this.name = name;
this.color = color;
}
// Method SayMiau
public void SayMiau()
{
Console.WriteLine("Cat {0} said: Miauuuuuu!
", name);
}
}
Some built-in classes
System.Console
System.String (string in C#)
System.Int32 (int in C#)
System.Array
System.Math
System.Random
9/27/2018
Dr.AtifShahzad
31
A BonusTopic
IE322
A BonusTopic
Conditional Operator
9/27/2018
Dr.AtifShahzad
33
Look at this example
int age = 42;
string msg;
if(age >= 18)
msg = "Welcome";
else
msg = "Sorry";
Console.WriteLine(msg);
9/27/2018
Dr.AtifShahzad
34
Conditional Operator
int age = 42;
string msg;
msg = (age >= 18) ? "Welcome" :
"Sorry";
Console.WriteLine(msg);
9/27/2018
Dr.AtifShahzad
35
Conditional Operator
What is the value of x after this code?
int x = 5;
int y = 3;
x = (x > y) ? y : x;
9/27/2018
Dr.AtifShahzad
36
Annex-
A Quick random revision
IE322
What is aVisual Studio Project?
When you create an
app, website, plug-in,
etc. inVisual Studio,
you start with a project.
9/27/2018
Dr.AtifShahzad
38
What is aVisual Studio Project?
When you create an app, website, plug-in, etc.
inVisual Studio, you start with a project.
In a logical sense, a project contains all the
source code files, icons, images, data files, etc.
that are compiled into an executable, library, or
website.
A project also contains compiler settings and
other configuration files that might be needed
by various services or components that your
program communicates with.9/27/2018
Dr.AtifShahzad
39
What is aVisual Studio Project?
A project is defined in an XML file with an
extension such as .vbproj, .csproj, or
.vcxproj.
This file contains a virtual folder hierarchy,
and paths to all the items in the project. It
also contains the build settings.
9/27/2018
Dr.AtifShahzad
40
What is aVisual Studio Project?
In Visual Studio, the project file is used by
Solution Explorer to display the project
contents and settings.
When you compile your project, the
MSBuild engine consumes the project file
to create the executable.You can also
customize projects to produce other kinds
of output.
9/27/2018
Dr.AtifShahzad
41
What is aVisual Studio Solution?
A project is contained within a solution. A
solution contains one or more related projects,
along with build information, Visual Studio
window settings, and any miscellaneous files
that aren't associated with a particular project.
A solution is described by a text file (extension
.sln) with its own unique format; it is generally
not intended to be edited by hand.
9/27/2018
Dr.AtifShahzad
42
What is aVisual Studio Solution?
A solution has an associated .suo file that stores
settings, preferences and configuration
information for each user that has worked on
the project.
9/27/2018
Dr.AtifShahzad
43
Project & Solution
9/27/2018
Dr.AtifShahzad
44
9/27/2018
Dr.AtifShahzad
46
NEVER hesitate to
contact should you
have any question
Dr.Atif Shahzad

More Related Content

Similar to Lecture08 computer applicationsie1_dratifshahzad

classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
arjun431527
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
Ray Toal
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
mwillmer
 

Similar to Lecture08 computer applicationsie1_dratifshahzad (20)

Lecture09 computer applicationsie1_dratifshahzad
Lecture09 computer applicationsie1_dratifshahzadLecture09 computer applicationsie1_dratifshahzad
Lecture09 computer applicationsie1_dratifshahzad
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API Requests
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Visual C++ project model
Visual C++ project modelVisual C++ project model
Visual C++ project model
 
Lecture13 ie321 dr_atifshahzad -algorithmic thinking
Lecture13 ie321 dr_atifshahzad -algorithmic thinkingLecture13 ie321 dr_atifshahzad -algorithmic thinking
Lecture13 ie321 dr_atifshahzad -algorithmic thinking
 
Looking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelopLooking for Bugs in MonoDevelop
Looking for Bugs in MonoDevelop
 
Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Introduction to Object oriented Design
Introduction to Object oriented DesignIntroduction to Object oriented Design
Introduction to Object oriented Design
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
 
Tutorial mvc (pelajari ini jika ingin tahu mvc) keren
Tutorial mvc (pelajari ini jika ingin tahu mvc) kerenTutorial mvc (pelajari ini jika ingin tahu mvc) keren
Tutorial mvc (pelajari ini jika ingin tahu mvc) keren
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0
 
DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006DRESD Project Presentation - December 2006
DRESD Project Presentation - December 2006
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
James Coplien: Trygve - Oct 17, 2016
James Coplien: Trygve - Oct 17, 2016James Coplien: Trygve - Oct 17, 2016
James Coplien: Trygve - Oct 17, 2016
 

More from Atif Shahzad

Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmeaDr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
Atif Shahzad
 
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
Atif Shahzad
 

More from Atif Shahzad (20)

Lecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzadLecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzad
 
Lecture03 computer applicationsie1_dratifshahzad
Lecture03 computer applicationsie1_dratifshahzadLecture03 computer applicationsie1_dratifshahzad
Lecture03 computer applicationsie1_dratifshahzad
 
Lecture01 computer applicationsie1_dratifshahzad
Lecture01 computer applicationsie1_dratifshahzadLecture01 computer applicationsie1_dratifshahzad
Lecture01 computer applicationsie1_dratifshahzad
 
Lecture02 computer applicationsie1_dratifshahzad
Lecture02 computer applicationsie1_dratifshahzadLecture02 computer applicationsie1_dratifshahzad
Lecture02 computer applicationsie1_dratifshahzad
 
Lecture02 computer applicationsie1_dratifshahzad
Lecture02 computer applicationsie1_dratifshahzadLecture02 computer applicationsie1_dratifshahzad
Lecture02 computer applicationsie1_dratifshahzad
 
Dr atif shahzad_sys_ management_lecture_agile
Dr atif shahzad_sys_ management_lecture_agileDr atif shahzad_sys_ management_lecture_agile
Dr atif shahzad_sys_ management_lecture_agile
 
Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmeaDr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
Dr atif shahzad_sys_ management_lecture_10_risk management_fmea_vmea
 
Dr atif shahzad_engg_ management_module_01
Dr atif shahzad_engg_ management_module_01Dr atif shahzad_engg_ management_module_01
Dr atif shahzad_engg_ management_module_01
 
Dr atif shahzad_engg_ management_lecture_inventory models
Dr atif shahzad_engg_ management_lecture_inventory modelsDr atif shahzad_engg_ management_lecture_inventory models
Dr atif shahzad_engg_ management_lecture_inventory models
 
Dr atif shahzad_engg_ management_lecture_inventory management
Dr atif shahzad_engg_ management_lecture_inventory managementDr atif shahzad_engg_ management_lecture_inventory management
Dr atif shahzad_engg_ management_lecture_inventory management
 
Dr atif shahzad_engg_ management_cost management
Dr atif shahzad_engg_ management_cost managementDr atif shahzad_engg_ management_cost management
Dr atif shahzad_engg_ management_cost management
 
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
Dr atif shahzad_sys_ management_lecture_outsourcing managing inter organizati...
 
Lecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_jsLecture17 ie321 dr_atifshahzad_js
Lecture17 ie321 dr_atifshahzad_js
 
Lecture16 ie321 dr_atifshahzad_css
Lecture16 ie321 dr_atifshahzad_cssLecture16 ie321 dr_atifshahzad_css
Lecture16 ie321 dr_atifshahzad_css
 
Lecture15 ie321 dr_atifshahzad_html
Lecture15 ie321 dr_atifshahzad_htmlLecture15 ie321 dr_atifshahzad_html
Lecture15 ie321 dr_atifshahzad_html
 
Lecture14 ie321 dr_atifshahzad -algorithmic thinking part2
Lecture14 ie321 dr_atifshahzad -algorithmic thinking part2Lecture14 ie321 dr_atifshahzad -algorithmic thinking part2
Lecture14 ie321 dr_atifshahzad -algorithmic thinking part2
 
Lecture12 ie321 dr_atifshahzad - networks
Lecture12 ie321 dr_atifshahzad - networksLecture12 ie321 dr_atifshahzad - networks
Lecture12 ie321 dr_atifshahzad - networks
 
Lecture11 ie321 dr_atifshahzad -security
Lecture11 ie321 dr_atifshahzad -securityLecture11 ie321 dr_atifshahzad -security
Lecture11 ie321 dr_atifshahzad -security
 
Lecture10 ie321 dr_atifshahzad
Lecture10 ie321 dr_atifshahzadLecture10 ie321 dr_atifshahzad
Lecture10 ie321 dr_atifshahzad
 
Lecture08 ie321 dr_atifshahzad
Lecture08 ie321 dr_atifshahzadLecture08 ie321 dr_atifshahzad
Lecture08 ie321 dr_atifshahzad
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

Lecture08 computer applicationsie1_dratifshahzad

  • 1. DR ATIF SHAHZAD Computer Applications in Industrial Engg.-I IE-322 LECTURE #08
  • 4. What we will see… 9/27/2018 Dr.AtifShahzad A Random Review A quick Question Classes • Class vs Object: Examples • Class vs Object: Adding a Class to a C# project Declaring a Class Adding a Method to the Class Instantiating an object of a class Calling a Method of an object Complete Example— class Car Solution Explorer Files of the project in Windows explorer Example2: Some built-in classes A BonusTopic • Look this example • Conditional Operator What is aVisual Studio Project? What is aVisual Studio Solution? Project & Solution
  • 5. A Random Review Dr.AtifShahzad 5 Data types are sets (ranges) of values that have similar characteristics.
  • 6. A Random Review Dr.AtifShahzad 6 DataTypes DefaultValue MinimumValue MaximumValue sbyte 0 -128 127 byte 0 0 255 short 0 -32768 32767 ushort 0 0 65535 int 0 -2147483648 2147483647 uint 0u 0 4294967295 long 0L -9223372036854775808 9223372036854775807 ulong 0u 0 18446744073709551615 float 0.0f ±1.5×10-45 ±3.4×1038 double 0.0d ±5.0×10-324 ±1.7×10308 decimal 0.0m ±1.0×10-28 ±7.9×1028 bool false Two possible values: true and false char 'u0000' 'u0000' 'uffff' object null - - string null - -
  • 7. A Random Review: Integer types Dr.AtifShahzad 7 // Declare some variables byte centuries = 20; ushort years = 2000; uint days = 730480; ulong hours = 17531520; // Print the result on the console Console.WriteLine(centuries + " centuries are " + years + " years, or " + days + " days, or " + hours + " hours. "); // Console output: // 20 centuries are 2000 years, or 730480 days, or 17531520 // hours. ulong maxIntValue = UInt64.MaxValue; Console.WriteLine(maxIntValue); // 18446744073709551615
  • 8. A Random Review: Real types Dr.AtifShahzad 8 // Declare some variables float floatPI = 3.141592653589793238f; double doublePI = 3.141592653589793238; // Print the results on the console Console.WriteLine("Float PI is: " + floatPI); Console.WriteLine("Double PI is: " + doublePI); // Console output: // Float PI is: 3.141593 // Double PI is: 3.14159265358979
  • 9. A quick Question 9/27/2018 Dr.AtifShahzad 9 int age = 8; if ( !(age >= 16) ) { Console.Write("Your age is less than 16"); } //What is the OUTPUT?
  • 10. A quick Question int age = 8; if ( !(age >= 16) ) { Console.Write("Your age is less than 16"); } // Outputs "Your age is less than 16" 9/27/2018 Dr.AtifShahzad 10
  • 12. Classes Classes act as templatesfrom which an instance of an object is created at run time. 9/27/2018 Dr.AtifShahzad 12
  • 13. Classes Classes act as templates from which an instance of an object is created at run time. Classes define the properties of the object and the methods used to control the object's behavior. 9/27/2018 Dr.AtifShahzad 13
  • 14. Class vs Object: Example 1 Dr.AtifShahzad 14 Drawing of House House
  • 15. Class vs Object: Example 2 Dr.AtifShahzad 15 Engineering Drawing of a car Car
  • 16. Class vs Object: Example 3 Dr.AtifShahzad 16 BankAccountclass Bank Account of a customer
  • 17. Class vs Object: Example 4 Dr.AtifShahzad 17 Student class A particular student
  • 18. Class vs Object:You examples? Dr.AtifShahzad 18 Class: Object: Attributes: Methods:
  • 19. Class vs Object: Dr.AtifShahzad 19 Class: Object: Attributes or States or Properties these are the characteristics of the object which define it in a way and describe it in general or in a specific moment Methods or Behaviors these are the specific distinctive actions, which can be done by the object. Methods:
  • 20. Adding a Class to a C# project Dr.AtifShahzad 20
  • 21. Declaring a Class Dr.AtifShahzad 21 Let us create a class named as Car namespace CarApp { class Car { } }
  • 22. Declaring a Class Dr.AtifShahzad 22 Let us create a class named as Car namespace CarApp { class Car { } // end class Car }//end namespace CarApp
  • 23. Adding a Method to the Class Dr.AtifShahzad 23 namespace CarApp { class Car { public void Start() { // A method Console.WriteLine("Car has been started"); } } // end class Car }//end namespace CarApp
  • 24. Instantiating an object of a class Dr.AtifShahzad 24 In the Main method of the Program: Car MyCar = new Car();
  • 25. Calling a Method of an object Dr.AtifShahzad 25 Access or dot (.) operator MyCar.Start();
  • 29. Files of the project inWindows explorer 9/27/2018 Dr.AtifShahzad 29
  • 30. Example2: Dr.AtifShahzad 30 public class Cat { // Field name private string name; // Field color private string color; public string Name { // Getter of the property "Name" get { return this.name; } // Setter of the property "Name" set { this.name = value; } } public string Color { // Getter of the property "Color" get { return this.color; } // Setter of the property "Color" set { this.color = value; } } // Default constructor public Cat() { this.name = "Unnamed"; this.color = "gray"; } // Constructor with parameters public Cat(string name, string color) { this.name = name; this.color = color; } // Method SayMiau public void SayMiau() { Console.WriteLine("Cat {0} said: Miauuuuuu!", name); } } public class Cat { // Field name private string name; // Field color private string color; public string Name { // Getter of the property "Name" get { return this.name; } // Setter of the property "Name" set { this.name = value; } } public string Color { // Getter of the property "Color" get { return this.color; } // Setter of the property "Color" set { this.color = value; } } // Default constructor public Cat() { this.name = "Unnamed"; this.color = "gray"; } // Constructor with parameters public Cat(string name, string color) { this.name = name; this.color = color; } // Method SayMiau public void SayMiau() { Console.WriteLine("Cat {0} said: Miauuuuuu! ", name); } }
  • 31. Some built-in classes System.Console System.String (string in C#) System.Int32 (int in C#) System.Array System.Math System.Random 9/27/2018 Dr.AtifShahzad 31
  • 34. Look at this example int age = 42; string msg; if(age >= 18) msg = "Welcome"; else msg = "Sorry"; Console.WriteLine(msg); 9/27/2018 Dr.AtifShahzad 34
  • 35. Conditional Operator int age = 42; string msg; msg = (age >= 18) ? "Welcome" : "Sorry"; Console.WriteLine(msg); 9/27/2018 Dr.AtifShahzad 35
  • 36. Conditional Operator What is the value of x after this code? int x = 5; int y = 3; x = (x > y) ? y : x; 9/27/2018 Dr.AtifShahzad 36
  • 37. Annex- A Quick random revision IE322
  • 38. What is aVisual Studio Project? When you create an app, website, plug-in, etc. inVisual Studio, you start with a project. 9/27/2018 Dr.AtifShahzad 38
  • 39. What is aVisual Studio Project? When you create an app, website, plug-in, etc. inVisual Studio, you start with a project. In a logical sense, a project contains all the source code files, icons, images, data files, etc. that are compiled into an executable, library, or website. A project also contains compiler settings and other configuration files that might be needed by various services or components that your program communicates with.9/27/2018 Dr.AtifShahzad 39
  • 40. What is aVisual Studio Project? A project is defined in an XML file with an extension such as .vbproj, .csproj, or .vcxproj. This file contains a virtual folder hierarchy, and paths to all the items in the project. It also contains the build settings. 9/27/2018 Dr.AtifShahzad 40
  • 41. What is aVisual Studio Project? In Visual Studio, the project file is used by Solution Explorer to display the project contents and settings. When you compile your project, the MSBuild engine consumes the project file to create the executable.You can also customize projects to produce other kinds of output. 9/27/2018 Dr.AtifShahzad 41
  • 42. What is aVisual Studio Solution? A project is contained within a solution. A solution contains one or more related projects, along with build information, Visual Studio window settings, and any miscellaneous files that aren't associated with a particular project. A solution is described by a text file (extension .sln) with its own unique format; it is generally not intended to be edited by hand. 9/27/2018 Dr.AtifShahzad 42
  • 43. What is aVisual Studio Solution? A solution has an associated .suo file that stores settings, preferences and configuration information for each user that has worked on the project. 9/27/2018 Dr.AtifShahzad 43
  • 45.
  • 46. 9/27/2018 Dr.AtifShahzad 46 NEVER hesitate to contact should you have any question Dr.Atif Shahzad