James Tam Introduction To Defining New Types in Pascal In this section of notes you how and why programmers can define new types.

Slides:



Advertisements
Similar presentations
Months of the year December January November October February
Advertisements

WALT: Know the months of the year poem. Answer questions about the months.
DOT 1 January , 1990 DOT 2 July 23 - August 3, 1990.
Chubaka Producciones Presenta :.
James Tam Introduction To Defining New Types in Pascal In this section of notes you will learn about programmer-defined types.
James Tam Introduction To Defining New Types in Pascal In this section of notes you how and why programmers can define new types.
2012 JANUARY Sun Mon Tue Wed Thu Fri Sat
January 2012 Monday Tuesday Wednesday Thursday Friday Sat/ Sun / /8 14/15 21/22 28/
P Pathophysiology Calendar. SundayMondayTuesdayWednesdayThursdayFridaySaturday January 2012.
Chicas, este calendario si es pa' nosotras !!!!!.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
2007 Monthly Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.

You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
Months of the Year Macarena song.
DATE POWER 2 INCOME JANUARY 100member X 25.00P2, FEBRUARY 200member X 25.00P5, MARCH 400member X 25.00P10, APRIL 800member.
Months of the year. jANUARY New year’s day fEBRUARY Valentine’s day.
Calendar for 2011 Months of the Year with Holidays.
2011 Calendar Important Dates/Events/Homework. SunSatFriThursWedTuesMon January
TEMPORAL VISUALIZATION OF DATA FROM THE FRENCH SENTINEL NETWORK.
July 2007 SundayMondayTuesdayWednesdayThursdayFridaySaturday
An introduction to outlining in PowerPoint
FY16 Budget Build (Banner)
Dictation practice 2nd Form Ms. Micaela-Ms. Verónica.
TIMELINES PHOTOS This is an example text
TIMELINES PHOTOS This is an example text
McDonald’s Kalender 2009.
McDonald’s Kalender 2009.
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
13-block rotation schedule
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
2017/18 Payment Calendar Due Date Cut-off Day 1st of every month
McDonald’s Kalender 2009.
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Problem Gambling Clicks to Opgr.org
2300 (11PM) September 21 Blue line is meridian..
January MON TUE WED THU FRI SAT SUN
McDonald’s calendar 2007.
1 - January - Sun Mon The Wed Thu Fri Sat
Proud As A Peacock! We are very proud of__________________
Teacher name August phone: Enter text here.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
February 2007 Note: Source:.
| January Sunday Monday Tuesday Wednesday Thursday Friday
January MON TUE WED THU FRI SAT SUN
MONTHS OF THE YEAR January February April March June May July August
S M T W F S M T W F
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
McDonald’s calendar 2007.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
Production Month Sun Hours K Monthly Kwh Tou Peak Value After Kwh
Habitat Changes and Fish Migration
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
2015 January February March April May June July August September
Habitat Changes and Fish Migration
Presentation transcript:

James Tam Introduction To Defining New Types in Pascal In this section of notes you how and why programmers can define new types.

James Tam Declaring Types Why bother? Creating your own type of variable Making a synonym for an existing type Format: Type Name(1) = Type for name (1); Name(2) = Type for name (2); : : : : Name(n) = Type for name (n);

James Tam Declaring Types (2) Can be used to provide alternative names for existing types Example: type FloatingPoint = real; var gpa : FloatingPoint; income: real;

James Tam Declaring Types (2) Can be used to provide alternative names for existing types Example: type FloatingPoint = real; var gpa : FloatingPoint; income: real; Declaring the type - defining what the type consists of (creating type) Declaring a variable of the new type (creating instances)

James Tam Declaring Types (3) Can be used to provide alternative names for existing types Example: type FloatingPoint = real; var gpa : FloatingPoint; income: real; Original type still usable

James Tam Where Type Declarations Fit Into Pascal Programs Header const (* Declaration of constants) type (* Declaration of new types *) var (* Declaration of global variables *) (* Declarations of functions & procedures – defining what they do *) Declarations begin : end. Statements

James Tam Programmer-Defined Ordinal Types Enumerated types Subrange

James Tam Enumerated Types Format: Type Name of type = (identifier 1, identifier 2..identifier n); Example: type Months = (January, February, March, April, May, June, July, August, September, October, November, December); Budget = array [January..December] of real; begin var tamjBudget : Budget; var monthsIndex : Months; for monthsIndex := January to December do tamjBudget[monthsIndex] := random(2000); end.

James Tam Operations On Enumerated Types OperationName Equity= Inequity<> Less than< Less than, equal to<= Greater than> Greater than, equal to>= Predecessorpred Successorsucc Ordinal Numberord

James Tam Examples Of Operations On Enumerated Types Pred if ((pred(February)) = January) then writeln('Jan comes before Feb'); Ord writeln(ord(January)); (As an ASCII converter) writeln(ord('A')); writeln(ord (chr(65))); writeln(chr(65));

James Tam Subrange Used to define a new type which is a subset of an existing type. Syntax: type Subrange name = first value..last value; Example: type Months = (January, February, March, April, May, June, July, August, September, October, November, December); FallTerm = September..December; WinterTerm = January..April;

James Tam You Should Now Know Why you need to create your own types How and where programmer defined types are created How to define and declare instances of enumerated types and subranges How to use enumerated types and subranges What operations are valid on enumerated types and how does each one work