How to program Enum Bit Flags 1
|
|
- Adam Spencer
- 6 years ago
- Views:
Transcription
1 How to program Enum Bit Flags 1 How to Program Enum Bit Flags When I started programming, I thought that I was the best. I would program if else statements and nested for loops. The complexity of programming was amazing. Seeing giant spikes of doom appear to the left of my programming environment was really cool as well. Then I learned about enum bit flags. This is my lesson to you, for those interested in programming enum bit flags. Enum variables are the bomb. Bit Flags are too. When combined, they become very powerful. By the end of this, you will learn everything that I know about using enums in C++ to their fullest. Without Bit Flags What happens if we want enumerations to be intelligent? For example, a human understands why mixing paint causes colors to change. Mixing blue and yellow paint together makes green paint. A computer does not know that, unless we program it. This is important, because if we have a program that asked the user to enter his or her favorite color, we could provide more than just a basic a response. With enum bit flags, which use bitwise operations, we can tell the user if he or she entered a primary color, its mixed contents, and more. Shown below, is how one would write a function to determine if a given color is a primary color. IsPrimary(Colors color) return (color == C_BLUE color == C_RED color == C_YELLOW) This is cool, but can we add just create another enum variable called IS_PRIMARY_COLOR? Also, we could have a variable ORANGE_PAINT_CONTENTS, and even ORANGE_LIGHT_CONTENTS. In order to do this, we need to change our enum a little bit.
2 How to program Enum Bit Flags 2 Power of Two The first change which must be made, is to have Colors equal to a power of two. This will make each number s binary value have a bunch of 0 s, and only one 1. As a result, each variable will have a 1 in a different digits place. That means, we can assign other values with more binary 1's. This is how we make our enums intelligent, and this is what a bit flag is. Also, C_NONE was changed to 0, because we may want to check set a color be empty, like and empty paint bucket, or a light that is turned off. C_NULL, which was added is -1, which would me no paint bucket, or no light switch. //Binary value C_NULL =-1, C_NONE = 0, C_RED = 1, C_BLUE = 2, C_YELLOW = 4, C_GREEN = 8, NUMBER_COLORS = 5 //This must be manually figured out. ; Enum Bit Flags Using the bitwise OR ' ', we can set enum variables to equal multiple values at the same time. As a result, we eliminate the need for if-else and switch style functions. In addition, our colors become intelligent. In addition, removing the need to create function, removes the hassle of adding extra function declaration in their corresponding header files and its implementation in the cpp file. //Binary value C_NULL = -1, //(i.e. no paint bucket, or no light switch) C_NONE = 0, //(i.e. empty paint bucket, or light switch set to off) C_RED = 1,
3 How to program Enum Bit Flags 3 C_BLUE = 2, C_YELLOW = 4, C_GREEN = 8, C_ORANGE = 16, C_PURPLE = 32, NUMBER_COLORS = 7, // //OR //OR //OR //OR //OR IS_PRIMARY_PAINT_COLOR = (C_RED C_BLUE C_YELLOW), // IS_PRIMARY_LIGHT_COLOR = (C_RED C_BLUE C_GREEN), // IS_SECONDARY_PAINT_COLOR = (C_GREEN C_ORANGE C_PURPLE), ORANGE_PAINT_CONTENTS = (C_RED C_YELLOW), YELLOW_LIGHT_CONTENTS = (C_GREEN C_RED), ; Are we done yet? Not yet. There is still a better way to implement out bit flags. For example, what happens if we have enum variables? Trying to calculate each and every enum value to the next power of two is unreasonable. Shifting Bits With a few simple changes, power of two calculations become super easy. The #define macro Fl(n), inserts a bit 1 at a given bit value. As a result, it calculates the power of two for us. Also, since enums are constant, and initialized at compile time, they cannot be assigned via a function call. The macro inserts the equation into the enum at compile time. The code shown below has the macro, and is implemented into the enumeration, Colors. Also, I have commented to the right of each line, what exactly is happening behind the scenes of the compiler. #define Fl(n) (1 << (n)) //Binary value C_NULL = -1, C_NONE = Fl(0), //1 << (0) == == 0 C_RED = Fl(1), //1 << (1) == == 1 C_BLUE = Fl(2), //1 << (2) == == 2 C_YELLOW = Fl(3), //1 << (3) == == 4 C_GREEN = Fl(4), //1 << (4) == == 8 C_ORANGE = Fl(5), //1 << (5) == == 16 C_PURPLE = Fl(6), //1 << (6) == == 32 NUMBER_COLORS = 7 //<-- You know that last was 6, NUMBER_COLORS must be 7 IS_PRIMARY_PAINT_COLOR = (C_RED C_BLUE C_YELLOW), IS_PRIMARY_LIGHT_COLOR = (C_RED C_BLUE C_GREEN), IS_SECONDARY_PAINT_COLOR = (C_GREEN C_ORANGE C_PURPLE), ORANGE_PAINT_CONTENTS = (C_RED C_YELLOW), YELLOW_LIGHT_CONTENTS = (C_GREEN C_RED), ; Accessing Enum Bit Flags It seems as if there is always a better way of programming variables. As with enum bit flags, the ability to access them is important too. Since we are using an array to store constants, as explained in the previous post, we need a way to access the proper index of the array, using our
4 How to program Enum Bit Flags 4 power of two enums. We can loop through the array using number of colors, and return the power of two. The opposite applies too. We can loop through Colors, and return the text from the corresponding array index. string ColorNames[NUMBER_COLORS] = "none", "red","blue","yellow", "green", "orange", purple"; Colors GetColor(string input) if(colornames[i] == input) return (Colors)Fl(i); return C_NULL; string GetColorName(Colors color) //Check if the color is a color, and not an intelligent operation if((int)color < Fl(NUMBER_COLORS)) if(color == Fl(i)) return ColorNames[i]; return "ERROR: Color does not exists"; return "ERROR: Not a vaild paramater value"; (Shown above) The first function, returns the, based on a given string. The second function returns a string, based on a given Color. These were adjusted to the now implemented bit flags. Enum Bit Flag Operations This is the final part. What happens if we want to check for something specific Like if a color is RED inside of an if statement? We need to use bit operators instead of regular logical operators. We can do that too. To check if an enum is equal to another enum, we use the bitwise operation = ; if(c_red = IS_PRIMARY_PAINT_COLOR) true //Bit flags, compared using = C_RED = IS_PRIMARY_PAINT_COLOR = RESULT: = //At least one bit must equal C_RED
5 How to program Enum Bit Flags 5 An example of when this would be important, is checking if the color that the use entered is both a primary color for both light and paint. We can write add the following code as a function bool IsColorDualPrimary(Colors color) //Method One: check bit values of each Colors enum return ((color = IS_PRIMARY_PAINT_COLOR) && (color = IS_PRIMARY_LIGHT_COLOR)); //Method Two: do a AND bit operation, and beck the enum against the result return (color = (IS_PRIMARY_PAINT_COLOR & IS_PRIMARY_LIGHT_COLOR)); //Method three: add the following code to the enum. I personally like method two better. //That is because long variable names can get really annoying IS_PRIMARY_PAINT_AND_LIGHT_COLOR = (IS_PRIMARY_PAINT_COLOR & IS_PRIMARY_LIGHT_COLOR); Separate Enum Flags Guess what, there is another way to improve our code. In the case where we have only a few Colors, and 1000 Flags, what happens to Colors? Does it represent the different colors on the visible spectrum, or does it represent a bunch of information relating to the colors? It would be best to put all of the enum flags in its own enumeration. This will also let the programming know that its contents are for bit flag operations. The data, and the operations should be separate. To do this, we make a new enum, and add _FLAGS to it. Also we change the prefix to CF_ for Color Flags. #define Fl(n) (1 << (n)) C_NULL = -1, C_NONE = Fl(0), C_RED = Fl(1), C_BLUE = Fl(2), C_YELLOW = Fl(3), C_GREEN = Fl(4), C_ORANGE = Fl(5), C_PURPLE = Fl(6), NUMBER_COLORS = 7 //<-- You know that last was 6, NUMBER_COLORS must be 7 ; enum ColorFlags CF_PRIMARY_PAINT_COLOR = (C_RED C_BLUE C_YELLOW),
6 How to program Enum Bit Flags 6 CF_PRIMARY_LIGHT_COLOR = (C_RED C_BLUE C_GREEN), CF_SECONDARY_PAINT_COLOR = (C_GREEN C_ORANGE C_PURPLE), CF_ORANGE_PAINT_CONTENTS = (C_RED C_YELLOW), CF_YELLOW_LIGHT_CONTENTS = (C_GREEN C_RED), ; Congratulations That is it. You are now are advanced at programming enum bit flags in C++. Here is the code: #include <string> #define Fl(n) (1 << (n)) C_NULL = -1, C_NONE = Fl(0), C_RED = Fl(1), C_BLUE = Fl(2), C_YELLOW = Fl(3), C_GREEN = Fl(4), C_ORANGE = Fl(5), C_PURPLE = Fl(6), NUMBER_COLORS = 7 //<-- You know that last was 6, NUMBER_COLORS must be 7 ; string ColorNames[NUMBER_COLORS] = "none", "red","blue","yellow", "green", "orange", purple"; enum ColorFlags CF_PRIMARY_PAINT_COLOR = (C_RED C_BLUE C_YELLOW), CF_PRIMARY_LIGHT_COLOR = (C_RED C_BLUE C_GREEN), CF_PRIMARY_PAINT_AND_LIGHT_COLOR = (IS_PRIMARY_PAINT_COLOR & IS_PRIMARY_LIGHT_COLOR); CF_SECONDARY_PAINT_COLOR = (C_GREEN C_ORANGE C_PURPLE), CF_ORANGE_PAINT_CONTENTS = (C_RED C_YELLOW), CF_YELLOW_LIGHT_CONTENTS = (C_GREEN C_RED), ; Colors GetColor(string input) if(colornames[i] == input) return (Colors)Fl(i); return C_NULL; string GetColorName(Colors color) //Check if the color is a color, and not an intelligent operation if((int)color < Fl(NUMBER_COLORS)) if(color == Fl(i))
7 How to program Enum Bit Flags 7 return ColorNames[i]; return "ERROR: Color does not exists"; return "ERROR: Not a valid parameter value"; Readers Challenge Alright, this is something I am starting to do. For this post, I challenge you to research how and when to use the AND, and XOR Operator. In addition, create the main function that revived use input, and displays the information about the color, using precalculated enum big flags.
There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.
Programming, Data Structures and Algorithms Prof. Hema Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 49 Module 09 Other applications: expression tree
More informationActivity Guide - Public Key Cryptography
Unit 2 Lesson 19 Name(s) Period Date Activity Guide - Public Key Cryptography Introduction This activity is similar to the cups and beans encryption we did in a previous lesson. However, instead of using
More information5 R1 The one green in the same place so either of these could be green.
Page: 1 of 20 1 R1 Now. Maybe what we should do is write out the cases that work. We wrote out one of them really very clearly here. [R1 takes out some papers.] Right? You did the one here um where you
More informationExcel for Algebra 1 Lesson 5: The Solver
Excel for Algebra 1 Lesson 5: The Solver OK, what s The Solver? Speaking very informally, the Solver is like Goal Seek on steroids. It s a lot more powerful, but it s also more challenging to control.
More informationEnums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.
Enums Introduction In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed. The Final Tag To display why this is useful, I m going to
More informationUsability Test Report: Bento results interface 1
Usability Test Report: Bento results interface 1 Summary Emily Daly and Ian Sloat conducted usability testing on the functionality of the Bento results interface. The test was conducted at the temporary
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 08 Constants and Inline Functions Welcome to module 6 of Programming
More informationQUIZ. What are 3 differences between C and C++ const variables?
QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,
More informationRIS shading Series #2 Meet The Plugins
RIS shading Series #2 Meet The Plugins In this tutorial I will be going over what each type of plugin is, what their uses are, and the basic layout of each. By the end you should understand the three basic
More informationChris' Makefile Tutorial
Chris' Makefile Tutorial Chris Serson University of Victoria June 26, 2007 Contents: Chapter Page Introduction 2 1 The most basic of Makefiles 3 2 Syntax so far 5 3 Making Makefiles Modular 7 4 Multi-file
More informationThe name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationError-Correcting Codes
Error-Correcting Codes Michael Mo 10770518 6 February 2016 Abstract An introduction to error-correcting codes will be given by discussing a class of error-correcting codes, called linear block codes. The
More informationOrbBasic LESSON 1 Goto and Variables Student Guide
OrbBasic LESSON 1 Goto and Variables Student Guide What is OrbBasic? OrbBasic is a programming language. A programming language is a list of instructions that tells a computer what to do. Although MacroLab
More informationLibrary Website Migration and Chat Functionality/Aesthetics Study February 2013
Library Website Migration and Chat Functionality/Aesthetics Study February 2013 Summary of Study and Results Georgia State University is in the process of migrating its website from RedDot to WordPress
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More informationDesign and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 02 Lecture - 45 Memoization
Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Module 02 Lecture - 45 Memoization Let us continue our discussion of inductive definitions. (Refer Slide Time: 00:05)
More informationLesson 1 Excel Tutorial Learning how to use Microsoft Excel 2010 page 1
Lesson 1 Excel Tutorial Learning how to use Microsoft Excel 2010 page 1 Step 1: When you first open up Excel 2010, this is what you will see. This is considered an Excel worksheet. Step 2: Notice the bottom
More informationChapter 1. Unit 1: Transformations, Congruence and Similarity
www.ck12.org Chapter 1. Unit 1: Transformations, Congruence and Similarity 1.16 Vertical Angles Here you ll learn to identify adjacent and vertical angles formed by intersecting lines and then find missing
More informationPolygons and Angles: Student Guide
Polygons and Angles: Student Guide You are going to be using a Sphero to figure out what angle you need the Sphero to move at so that it can draw shapes with straight lines (also called polygons). The
More informationPart 1 Simple Arithmetic
California State University, Sacramento College of Engineering and Computer Science Computer Science 10A: Accelerated Introduction to Programming Logic Activity B Variables, Assignments, and More Computers
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationOrbBasic Lesson 1 Goto and Variables: Student Guide
OrbBasic Lesson 1 Goto and Variables: Student Guide Sphero MacroLab is a really cool app to give the Sphero commands, but it s limited in what it can do. You give it a list of commands and it starts at
More informationOrbBasic 1: Student Guide
OrbBasic 1: Student Guide Sphero MacroLab is a really cool app to give the Sphero commands, but it s limited in what it can do. You give it a list of commands and it starts at the top and goes to the bottom,
More informationHow invariants help writing loops Author: Sander Kooijmans Document version: 1.0
How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the
More informationInstructions for Crossword Assignment CS130
Instructions for Crossword Assignment CS130 Purposes: Implement a keyboard interface. 1. The program you will build is meant to assist a person in preparing a crossword puzzle for publication. You have
More informationTranscription of The Magic Picture" Lesson
First Segment: Transcription of The Magic Picture" Lesson Once upon a time, a woman came to a ruler and said," I complain to you that I do not have mice at my place!" People around the ruler started wondering,
More informationThe way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false
5 Conditionals Conditionals 59 That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted. George Boole The way I feel about music
More informationNCMail: Microsoft Outlook User s Guide
NCMail: Microsoft Outlook 2003 Email User s Guide Revision 1.0 11/10/2007 This document covers how to use Microsoft Outlook 2003 for accessing your email with the NCMail Exchange email system. The syntax
More informationESCAPE. A MINWOO PARK FILM Press Kit
ESCAPE A MINWOO PARK FILM Press Kit WWW.MINU-PARK.COM Director@minu-park.com 1-646-944-6726 Logline An alien lost her part, and falls into Manhattan at night. She needs to retrieve her part in order to
More information16. Linked Structures and Miscellaneous
16. Linked Structures and Miscellaneous The main purpose of this section is to look at the cool topic of linked data structures. This is where we use one object to point to the next object in a structure
More informationIn this lesson, you ll learn how to:
LESSON 5: ADVANCED DRAWING TECHNIQUES OBJECTIVES In this lesson, you ll learn how to: apply gradient fills modify graphics by smoothing, straightening, and optimizing understand the difference between
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationThe smarter, faster guide to Microsoft Outlook
The smarter, faster guide to Microsoft Outlook Settings... 1 The Inbox... 1 Using E-Mail... 4 Sending Attachments... 6 Some things to watch out for with File Attachments:... 7 Creating an Email Signature...
More informationTip 63: Seamlessly extend C structures
Tip 63: Seamlessly extend C structures Ben Klemens 5 February 2012 level: Compose structs purpose: Inherit [January 2015: It seems I have to add a caveat for this tip. Before I do, I d like to point out
More information(Refer Slide Time: 01.26)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.
More informationSIMPLE PROGRAMMING. The 10 Minute Guide to Bitwise Operators
Simple Programming SIMPLE PROGRAMMING The 10 Minute Guide to Bitwise Operators (Cause you've got 10 minutes until your interview starts and you know you should probably know this, right?) Twitter: Web:
More informationSmarties Estimate and Count
Smarties Estimate and Count ACTIVITY 1 STEP 1: DO NOT OPEN THE SMARTIES This activity will teach you how to use spreadsheets. You will use a box of Smarties to compile data to complete the spreadsheet.
More informationMicrocontrollers. Outline. Class 1: Serial and Digital I/O. March 7, Quick Tour of the Board. Pins, Ports, and Their Registers
Microcontrollers Class 1: Serial and Digital I/O March 7, 2011 Outline Quick Tour of the Board Pins, Ports, and Their Registers Boolean Operations Cylon Eyes Digital Input and Testing Particular Pin States
More informationUniversity of Utah School of Computing
University of Utah School of Computing CS 1410 / CS 2000 Study Notes December 10, 2011 This study guide is designed to help you prepare and study the appropriate material for the final exam. For the multiple
More informationTopic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History
Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More information6.001 Notes: Section 8.1
6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything
More informationCOSC345 Software Engineering. Documentation
COSC345 Software Engineering Documentation Documentation Self-documenting code Comments Outline Documentation And Comments McConnell Most developers like writing documentation If the standards aren t unreasonable
More informationHash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell
Hash Tables CS 311 Data Structures and Algorithms Lecture Slides Wednesday, April 22, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005
More informationAADL Graphical Editor Design
AADL Graphical Editor Design Peter Feiler Software Engineering Institute phf@sei.cmu.edu Introduction An AADL specification is a set of component type and implementation declarations. They are organized
More informationIntroduction. Three button technique. "Dynamic Data Grouping" using MS Reporting Services Asif Sayed
Image: 1.0 Introduction We hear this all the time, Two birds with one stone. What if I say, Four birds with one stone? I am sure four sound much better then two. So, what are my four birds and one stone?
More informationTeach Yourself Microsoft Word Topic 10 - Margins, Indents and Tabs
http://www.gerrykruyer.com Teach Yourself Microsoft Word Topic 10 - Margins, Indents and Tabs In the previous Level 2 MS Word course: Topic 8 you covered columns, text boxes and tables as well as look
More informationDemo Scene Quick Start
Demo Scene Quick Start 1. Import the Easy Input package into a new project. 2. Open the Sample scene. Assets\ootii\EasyInput\Demos\Scenes\Sample 3. Select the Input Source GameObject and press Reset Input
More informationMaking ecards Can Be Fun!
Making ecards Can Be Fun! A Macromedia Flash Tutorial By Mike Travis For ETEC 664 University of Hawaii Graduate Program in Educational Technology April 4, 2005 The Goal The goal of this project is to create
More informationQUIZ Friends class Y;
QUIZ Friends class Y; Is a forward declaration neeed here? QUIZ Friends QUIZ Friends - CONCLUSION Forward (a.k.a. incomplete) declarations are needed only when we declare member functions as friends. They
More informationProgramming Exercise 14: Inheritance and Polymorphism
Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.
More informationEL6483: Brief Overview of C Programming Language
EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions
More informationEVALUATION ASSIGNMENT 2
EVALUATION ASSIGNMENT 2 CS5760 Graduate Human-Computer Interaction Abstract An investigation of the user interface domain, heuristic principles, and critical usability concerns for the current design and
More informationRhombic Hexacontahedron in Google SketchUp
Check out this cool-looking shape: You can read more about it here: http://mathworld.wolfram.com/rhombichexecontahedron.html. It looks sort of complicated, and I ll admit it takes a number of steps to
More informationArduino IDE Friday, 26 October 2018
Arduino IDE Friday, 26 October 2018 12:38 PM Looking Under The Hood Of The Arduino IDE FIND THE ARDUINO IDE DOWNLOAD First, jump on the internet with your favorite browser, and navigate to www.arduino.cc.
More informationClient Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module
Basic Class Design Goal of OOP: Reduce complexity of software development by keeping details, and especially changes to details, from spreading throughout the entire program. Actually, the same goal as
More informationWe will start our journey into Processing with creating static images using commands available in Processing:
Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find
More informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationIn our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.
Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts
More informationSASS Variables and Mixins Written by Margaret Rodgers. Variables. Contents. From Web Team. 1 Variables
SASS Variables and Mixins Written by Margaret Rodgers From Web Team Contents 1 Variables o 1.1 Nested Variables 2 Mixins 3 Inheritance Variables A variable in SASS works exactly the same as a variable
More informationQUIZ. What is wrong with this code that uses default arguments?
QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code
More informationCS354 gdb Tutorial Written by Chris Feilbach
CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that
More informationBINARY FOR THE YOUNGER SET
BINARY FOR THE YOUNGER SET OR WHY COMPUTERS USE A BINARY SYSTEM TO DO WHAT THEY DO BEST T. I. S. P. Teachers in Service Program FIRST, ONE SIMPLE GROUND RULE Yes, I know we write all our letters starting
More informationTopic 6: A Quick Intro To C
Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions
More information205CDE: Developing the Modern Web. Assignment 1: Designing a Website. Scenario: D Bookshop
205CDE: Developing the Modern Web Assignment 1: Designing a Website Scenario: D Bookshop Introduction I decided to make a second hand bookshop website. There are some reasons why I made this choice. Mainly
More information/* defines are mostly used to declare constants */ #define MAX_ITER 10 // max number of iterations
General Framework of a C program for MSP430 /* Compiler directives (includes & defines) come first */ // Code you write in this class will need this include #include msp430.h // CCS header for MSP430 family
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG 1 Notice Class Website http://www.cs.umb.edu/~jane/cs114/ Reading Assignment Chapter 1: Introduction to Java Programming
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationCSS worksheet. JMC 105 Drake University
CSS worksheet JMC 105 Drake University 1. Download the css-site.zip file from the class blog and expand the files. You ll notice that you have an images folder with three images inside and an index.html
More informationC - Basics, Bitwise Operator. Zhaoguo Wang
C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled
More informationThe Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home
A l l e n I. H o l u b & A s s o c i a t e s Home C/C++ and OO Rules of Thumb The following list is essentially the table of contents for my book Enough Rope to Shoot Yourself in the Foot (McGraw-Hill,
More informationLearn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step
EXCELL MASTERY Learn Ninja-Like Spreadsheet Skills with LESSON 9 Doing Math, Step by Step It s Elementary, My Dear Ninja There is a scene in the short story The Crooked Man, where Sherlock Holmes accurately
More informationMath-2. Lesson 3-1. Equations of Lines
Math-2 Lesson 3-1 Equations of Lines How can an equation make a line? y = x + 1 x -4-3 -2-1 0 1 2 3 Fill in the rest of the table rule x + 1 f(x) -4 + 1-3 -3 + 1-2 -2 + 1-1 -1 + 1 0 0 + 1 1 1 + 1 2 2 +
More informationData Visualization (CIS 468)
Data Visualization (CIS 468) Web Programming Dr. David Koop What is Data Visualization? 2 Exploration Communication Spectrum Consecutive Starts by a Quarterback for a Single Team Exploration Confirmation
More informationThe art of using fonts and colours in text
Lesson 6 Revision The art of using fonts and colours in text Aim In this lesson you will learn: What is a font and why it is important to choose fonts carefully. How to use different font types, sizes,
More informationAnswer Key Lesson 11: Workshop: Shapes and Properties
Answer Key esson 11: Use the nine Power Polygons below for Questions 1 and 2. 1. A. Sort the shapes with four sides into ox A. Sort the Shapes with one or more right angles into ox. Some shapes will go
More informationProgramming with Haiku
Programming with Haiku Lesson 17 Written by DarkWyrm All material 2011 DarkWyrm The Interface Kit is all about creating and using controls for the graphical interface. In some of the earlier lessons, we
More informationArithmetic-logic units
Arithmetic-logic units An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the heart of a processor you could say that everything else in the CPU is there
More informationLesson 4: Who Goes There?
Lesson 4: Who Goes There? In this lesson we will write a program that asks for your name and a password, and prints a secret message if you give the right password. While doing this we will learn: 1. What
More informationCS125 : Introduction to Computer Science. Lecture Notes #11 Procedural Composition and Abstraction. c 2005, 2004 Jason Zych
CS125 : Introduction to Computer Science Lecture Notes #11 Procedural Composition and Abstraction c 2005, 2004 Jason Zych 1 Lecture 11 : Procedural Composition and Abstraction Solving a problem...with
More informationInfix to Postfix Conversion
Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation
More informationKarlen Communications Track Changes and Comments in Word. Karen McCall, M.Ed.
Karlen Communications Track Changes and Comments in Word Karen McCall, M.Ed. Table of Contents Introduction... 3 Track Changes... 3 Track Changes Options... 4 The Revisions Pane... 10 Accepting and Rejecting
More informationThe Java Type System (continued)
Object-Oriented Design Lecture 5 CSU 370 Fall 2007 (Pucella) Friday, Sep 21, 2007 The Java Type System (continued) The Object Class All classes subclass the Object class. (By default, this is the superclass
More informationThe C# Programming Yellow Book Free Ebooks PDF
The C# Programming Yellow Book Free Ebooks PDF Learn C# from first principles the Rob Miles way. With jokes, puns, and a rigorous problem solving based approach.you can download all the code samples used
More informationc122mar413.notebook March 06, 2013
These are the programs I am going to cover today. 1 2 Javascript is embedded in HTML. The document.write() will write the literal Hello World! to the web page document. Then the alert() puts out a pop
More informationSEARCH BASICS. Locate the handout, Assignment for lesson 12, for this search basics tutorial. Questions in red are those you ll answer on the handout.
SEARCH BASICS Locate the handout, Assignment for lesson 12, for this search basics tutorial. Questions in red are those you ll answer on the handout. LIBRARY CATALOG BASICS Library Catalog: a database
More information5.6.1 The Special Variable this
ALTHOUGH THE BASIC IDEAS of object-oriented programming are reasonably simple and clear, they are subtle, and they take time to get used to And unfortunately, beyond the basic ideas there are a lot of
More informationThe Pascal Programming Language. Bob Fraley HP Labs. January 15, 1980
The Pascal Programming Language Bob Fraley HP Labs January 15, 1980 The Pascal language has gained popularity in recent years. It has a number of features which simplify programming and make programs more
More informationAssignment 4 One and two dimensional arrays
Programming Using C#, Basic Course Assignment 4 One and two dimensional arrays Help and guidance Cinema Booking System Version 2 Farid Naisan University Lecturer Department of Computer Sciences Malmö University,
More informationEasy List Building System
Easy List Building System By Muhammad Ali Contents Introduction... 3 Step 1: Find a Quality PLR Product... 4 Step 2: Create Your Squeeze Page... 6 Seven Rules to Follow... 6 Step 3: Set Up Your Download
More informationTranscript: Meet Hope Military Spouse and Learning Coach
Transcript: Meet Hope Military Spouse and Learning Coach Transcript (Video) Transcript (Video with Audio Description) Transcript (Audio Description) Transcript (Video) [00:00:00.000] (upbeat music) [00:00:04.977]
More informationDesign and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso
Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Why C? Test on 21 Android Devices with 32-bits and 64-bits processors and different versions
More informationBinghamton University. CS-211 Fall Variable Scope
Variable Scope 1 Scope The places in your code that can read and/or write a variable. Scope starts at the location where you declare the variable There may be holes in the scope! Scope ends at the end
More informationBinghamton University. CS-211 Fall Variable Scope
Variable Scope 1 Scope The places in your code that can read and/or write a variable. Scope starts at the location where you declare the variable There may be holes in the scope! Scope ends at the end
More informationGeometry. Talk About It. Solve It. More Ideas. Formative Assessment
2 7.G.2 Objective Common Core State Standards Construct Triangles Triangles are polygons with three sides, and they are classified by their sides and angles. The sum of the angles of any triangle is 180,
More informationBusiness Writing In English
Business Writing In English It isn t always easy to write a clear, concise e-mail or a formal letter in another language. Often, we know words and phrases we should use, but putting everything together
More informationWhat will you learn: A better understanding of 3 D space How to use keyframes Designing and planning an animation How to render animations
Intro to Blender Introductory Animation Shane Trautsch Crestwood High School Welcome Back! Blender can also be used for animation. In this tutorial, you will learn how to create simple animations using
More informationPracticum 5 Maps and Closures
Practicum 5 Maps and Closures Assignment Details Assigned: February 18 th 2014. Due: February 20 th, 2014 at midnight. Background One of the requirements of PA1 Part 2 using a data structure to hold function
More informationSlide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng
Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide
More information