1. Trang chủ
  2. » Công Nghệ Thông Tin

Ebook Visual C#® for kids (15th edition): Part 1

209 2 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Visual C#® For Kids (15th Edition): Part 1
Tác giả Philip Conrod, Lou Tylee
Trường học Kidware Software LLC
Chuyên ngành Computer Programming
Thể loại Textbook
Năm xuất bản 2017
Thành phố Maple Valley
Định dạng
Số trang 209
Dung lượng 4,48 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Part 1 of ebook Visual C#® for kids (15th edition) presents the following content: introducing Visual C#; the visual C# design environment; your first visual C# project; project design, forms, buttons; labels, text boxes, variables; updown control, decisions, random numbers;...

Trang 2

Visual C# ® For Kids

15th Edition

ByPhilip Conrod & Lou Tylee

©2017 Kidware Software LLC

Kidware Software LLC

PO Box 701Maple Valley, WA 98038

http://www.computerscienceforkids.comhttp://www.kidwaresoftware.com

Trang 3

This guide was developed for the course, “Visual C# For Kids,” produced by Kidware Software, Maple Valley, Washington It is not intended to be a complete reference to the Visual C# language Please consult the Microsoft website for detailed reference information.

This guide refers to several software and hardware products by their trade names These references are for informational purposes only and all trademarks are the property of their respective companies and owners Microsoft, Visual Studio, Small Basic, Visual Basic, Visual J#, and Visual C#, IntelliSense, Word, Excel, MSDN, and Windows are all trademark products of the Microsoft Corporation Java is a trademark product

of the Oracle Corporation.

The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted are fictitious No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred.

Trang 4

This book expresses the author’s views and opinions The information in this book is distributed on an "as is" basis, without and expresses, statutory, or implied warranties.

Neither the author(s) nor Kidware Software LLC shall have any liability to any person or entity with respect

to any loss nor damage caused or alleged to be caused directly or indirectly by the information contained in this book.

Trang 5

About The Authors Philip Conrod has authored, co-authored and edited numerous computer programming books for kids, teens and adults Philip holds a BS in Computer

Information Systems and a Master's certificate in the Essentials of Business Development from Regis University He also holds a Certificate in Programming for Business from WarrenTech Philip has been programming computers since 1977 He has also held various Information Technology leadership roles in companies like Sundstrand Aerospace, Safeco Insurance Companies, FamilyLife, Kenworth Truck

Company, PACCAR and Darigold Inc In his spare time, Philip serves as the President & Publisher of Kidware Software, LLC He is the proud father of three “techie” daughters and lives in Maple Valley, Washington.

Lou Tylee holds BS and MS degrees in Mechanical Engineering and a PhD in Electrical Engineering Lou has been programming computers since 1969 when he took his first Fortran course in college He has written software to control suspensions for high speed ground vehicles, monitor nuclear power plants, lower noise levels in commercial jetliners, compute takeoff speeds for jetliners, locate and identify air and ground traffic and to let kids count bunnies, learn how to spell and do math problems He has written several on- line texts teaching Visual Basic, Visual C# and Java to thousands of people He taught a beginning Visual Basic course for over 15 years at a major university Currently, Lou works as an engineer at a major Seattle aerospace firm He is the proud father of five children and proud husband of his special wife Lou and his family live in Seattle, Washington.

Trang 6

I want to thank my three wonderful daughters - Stephanie, Jessica and Chloe, who helped with various aspects of the book publishing process including software testing, book editing, creative design and many other more tedious tasks like finding errors and typos I could not have accomplished this without all your hard work, love and support I want to also thank my best friend Jesus, who has always been there by my side giving me wisdom and guidance Without you, this book would have never been printed and published.

I also want to thank my multi-talented co-author, Lou Tylee, for doing all the real hard work necessary to develop, test, debug, and keep current all the ‘beginner-friendly’ applications, games and base tutorial text found in this book Lou has tirelessly poured his heart and soul into so many previous versions of this tutorial and there are so many beginners who have benefited from his work over the years Lou is by far one

of the best application developers and tutorial writers I have ever worked with Thank you Lou for collaborating with me on this book project.

Trang 8

Parts of a Visual C# Project

Parts of the Visual C# Environment

Starting a New Visual C# ProjectMain Window

Example

Setting Control Properties (Design Mode)Naming Controls

Trang 9

How Control Names are Used in Event MethodsWriting Event Methods

Trang 11

Project Design

Place Controls on Form

Set Control Properties

Trang 14

Example

Events

Typical Use of Radio Button ControlC# - The Fourth Lesson

Trang 15

C# - The Fifth LessonMouse Events

MouseDown EventExample

MouseUp Event

Example

MouseMove EventExample

Project - Blackboard FunProject Design

Place Controls on FormSet Control PropertiesWrite Event Methods

Trang 18

Project – Beach Balls

Project Design

Place Controls on FormSet Control PropertiesWrite Event MethodsRun the Project

Other Things to TrySummary

Bonus Projects

Preview

Project 1 – StopwatchProject Design

Place Controls on FormSet Control PropertiesWrite Event MethodsRun the Project

Other Things to TryProject 2 - Tic-Tac-ToeProject Design

Place Controls on Form

Trang 19

Other Things to TryProject 3 - Dice RollingProject Design

Place Controls on FormSet Control PropertiesWrite Event MethodsRun the Project

Other Things to TryProject 4 - State CapitalsProject Design

Place Controls on FormSet Control PropertiesWrite Event MethodsRun the Project

Other Things to TryProject 5 - Memory GameProject Design

Place Controls on Form

Trang 21

tutorial providing a complete introduction to the Visual C# programming

language and environment The tutorial consists of 10 lessons explaining (insimple, easy-to-follow terms) how to build a Visual C# application Numerousexamples are used to demonstrate every step in the building process The tutorial

also includes detailed computer projects for kids to build and try Visual C# for

Kids is presented using a combination of course notes (written in Microsoft

Word format) and many Visual C# examples and projects

Trang 22

comfortable working within the Windows environment, knowing how to find

files, move windows, resize windows, etc No programming experience is

needed The course material should be understandable to kids aged 10 and up.You will also need the ability to view and print documents saved in Adobe

Acrobat format

Software Requirements To use Visual C#, you need to have theVisual Studio 2015 Community Edition product installed on your computer It isavailable for free download from Microsoft Follow this link for complete

instructions for downloading and installing Visual Studio 2015 ComminityEdition on your computer: https://www.visualstudio.com/products/free-

developer-offers-vs

Trang 23

“Visual C# for Kids,” it is not necessarily written in a kid’s vocabulary

Computer programming has a detailed vocabulary of its own and, since adultsdeveloped it, the terminology tends to be very adult-like In developing thiscourse, we discussed how to address this problem and decided we would treatour kid readers like adults, since they are learning what is essentially an adulttopic We did not want to ‘dumb-down’ the course You see this in some books

We, quite frankly, are offended by books that refer to readers as dummies andidiots simply because they are new to a particular topic We didn’t want to dothat here Throughout the course, we treat the kid reader as a mature personlearning a new skill The vocabulary is not that difficult, but there may be timesthe kid reader needs a little help Hopefully, the nearest adult can provide thathelp

Trang 24

If you purchased this directly from our website you received an email with aspecial and individualized internet download link where you could download thecompressed Program Solution Files If you purchased this book through a 3rdParty Book Store like Amazon.com, the solutions files for this tutorial are

included in a compressed ZIP file that is available for download directly fromour website at: http://www.kidwaresoftware.com/VCS2015kids-registration.html

Complete the online web form at the webpage above with your name, shippingaddress, email address, the exact title of this book, date of purchase, online orphysical store name, and your order confirmation number from that store After

we receive all this information we will email you a download link for the SourceCode Solution Files associated with this book

Warning: If you purchased this book “used” or “second hand” you are not

licensed or entitled to download the Program Solution Files However, you canpurchase the Digital Download Version of this book at a discounted price whichallows you access to the digital source code solutions files required forcompleting this tutorial

Trang 25

for Kids are included in one or more ZIP files Use your favorite ‘unzipping’

application to write all files to your computer The course is included in the

folder entitled VCSKids This folder contains two other folders: VCSK Notes and VCSK Projects The VCSK Projects folder includes all the Visual C#

projects developed during the course

Trang 26

course The suggested approach is to do one class a week for ten weeks Eachweek’s class should require about 3 to 6 hours of your time to grasp the conceptscompletely Prior to doing a particular week’s work, open the class notes file forthat week and print it out Then, work through the notes at your own pace Try to

do each example as they are encountered in the notes Work through the projects

in Classes 3 through 10 (and the Bonus class) If you need any help, all

completed projects are included in the VCSK Projects folder.

Trang 27

“controls” to make programs which look like “Windows” programs Thecontrols are combined to provide the user with a GUI – a graphical userinterface.

The tutorials provide the benefit of completed age-appropriate applications forchildren – fully documented projects from the teacher’s or parents’ point ofview That is, while full solutions are provided for the adults’ (and childlearner’s) benefit, the projects are presented in an easy-to-follow set of lessonsexplaining the rational for the form layout, coding design and conventions, andspecific code related to the problem The child-learner may follow the tutorials

at their own pace Every bit of the lesson is remembered as it contributes to thefinal solution to a kid-friendly application The finished product is the reward,but the student is fully engaged and enriched by the process This kind oflearning is often the focus of teacher training Every computer science teacherknows what a great deal of work required for projects to work in this manner,and with these tutorials, the work is done by an author who understands theclassroom and parenting experience That is extremely rare!

Graduated Lessons for Every Project … Lessons, examples, problems and projects Graduated learning Increasing and appropriate difficulty… Great results.

With these projects, there are lessons providing a comprehensive, kid-friendlybackground on the programming topics to be covered Once understood,concepts are easily applicable to a variety of applications Then, specificexamples are drawn out so that a young learner can practice with the Visual C#

Trang 28

By presenting lessons in this graduated manner, students are fully engaged andappropriately challenged to become independent thinkers who can come up withtheir own project ideas and design their own forms and do their own coding.Once the process is learned, then student engagement is unlimited! I have seenliteracy improve dramatically when students cannot get enough of what is beingpresented

Indeed, lessons encourage accelerated learning – in the sense that they provide

an enriched environment to learn computer science, but they also encourageaccelerating learning because students cannot put the lessons away once theystart! Computer science provides this unique opportunity to challenge students,and it is a great testament to the authors that they are successful in achievingsuch levels of engagement with consistency

My History with Kidware Software products.

I have used Kidware’s Programming Tutorials for over a decade to keep up myown learning By using these lessons, I am able to spend time on things whichwill pay off in the classroom I do not waste valuable time ensconced inlanguage reference libraries for programming environments – help screenswhich can never be fully remembered! These projects are examples of howstudent projects should be as final products – thus, the pathway to learning isclear and immediate in every project

If I want to have students use or expand upon projects, then I take advantage ofsite-license options I have found it very straight forward to emphasize thefundamental computer science topics that form the basis of these projects whenusing them in the classroom I can list some computer science topics whicheveryone will recognize, regardless of where they teach – topics which arecovered expertly by these tutorials:

• Data Types and Ranges

• Scope of Variables

• Naming Conventions

Trang 29

Any further Middle school computer programming topics derive directly fromthose listed above Nothing is forgotten All can be integrated with the lessonsprovided.

Quick learning curve for teachers! How teachers can use the product:

Having projects completed ahead of time can allow the teacher to present thedesign aspect of the project FIRST, and then have students do all of theirlearning in the context of what is required in the finished product This is a muchfaster learning curve than if students designed all of their own projects fromscratch Lessons concentrating on a unified outcome for all makes for muchmore streamlined engagement for students (and that is what they need, in Middleschool, and in grades 9 and 10), as they complete more projects within a shortperiod of time and there is a context for everything that is learned

After the process of form-design, naming controls and coding has been masteredfor a given set of Visual C# controls, then it is much more likely that studentscan create their own problems and solutions from scratch Students are ready tocreate their own summative projects for your computer science course – or justfor fun, and they may think of projects for their other courses as well! And whatcould be wrong with asking the students’ other teachers what they would like tosee as project extensions?

Meets State and Provincial Curriculum Expectations and More

Trang 30

Different states and provinces have their own curriculum requirements forcomputer science With the Kidware Software products, you have at yourdisposal a series of projects which will allow you to pick and choose fromamong those which best suit your curriculum needs Students focus upon designstages and sound problem-solving techniques from a computer-science,problem-solving perspective In doing so, they become independent problem-solvers, and will exceed the curricular requirements of Middle schoolseverywhere.

Useable projects – Out of the box!

The specific projects covered in the Visual C# for Kids tutorials are suitable forstudents aged 10 and above Specific kid-friendly tutorials and projects are found

How to teach students to use the materials.

In a Middle school situation, parents or teachers might be tempted to spendconsiderable amounts of time at the projector or computer screen going over thetutorial – but the best strategy is to present the finished product first! That way,provided that the adult has covered the basic concepts listed in the table of

Trang 31

contents, then students will quickly grasp how to use the written lessons on theirown Lessons will be fun, and the pay-off for younger students is that there isalways a finished product which is fun to use!

Highly organized reference materials for student self-study!

Materials already condense what is available from MSDN (which tends to bewritten for adults) and in a context and age-appropriate manner, so that youngerstudents remember what they learn The time savings for parents, teachers andstudents is enormous as they need not sift through pages and pages of on-linehelp to find what they need

How to mark the projects.

In a classroom environment, it is possible for teachers to mark student progress

by asking questions during the various design and coding stages In the earlygrades (grades 5 to 8) teachers can make their own oral, pictorial review orwritten pop quizzes easily from the reference material provided as a reviewstrategy from day to day I have found the requirement of completing projects(mastery) sufficient for gathering information about student progress –especially in the later grades (grades 10 to 12)

Lessons encourage your own programming extensions.

Once concepts are learned, it is difficult to NOT know what to do for your ownprojects This is true even at the Middle school level – where applications can bemade in as short as 10 minutes (a high-low guessing game, or a temperatureconversion program, for example), or 1 period in length – if one wished toexpand upon any of the projects using the “Other Things to Try” suggestions

Having used Kidware Software tutorials for the past decade, I have to say that Icould not have achieved the level of success which is now applied in the variety

of many programming environments which are currently of considerable interest

to kids! I thank Kidware Software and its authors for continuing to stand forwhat is right in the teaching methodologies which work with kids – even today’skids where competition for their attention is now so much an issue.”

Regards,

Alan Payne, B.A.H., B.Ed.,

TA Blakelock High School,

Trang 32

http://chatt.hdsb.ca/~paynea

Trang 33

1 Introducing Visual C# Express

Trang 34

Back in the early 1970’s, Bill and Paul were friends atLakeside School in Seattle, Washington Bill and Paulenjoyed working with computers and wrote many games theycould play - games like Tic-Tac-Toe and moon landinggames These computer games were written in a computer

language called BASIC (which stands for Beginner’s Purpose Symbolic Instruction Code) When the first small

All-computer was developed in the mid 1970’s, Bill and Paul had just startedcollege They had improved their computer skills by then and were able to tellthat new computer how to use the BASIC language They actually sold theirversion of the BASIC language to other people (it cost $350 and was stored on acassette tape) They started making money selling BASIC and decided to start acompany You may have heard of their company - Microsoft! Bill is Bill Gates,who still runs Microsoft and is worth many billions of dollars, and Paul is PaulAllen, who no longer works for Microsoft, but has his own business venturesincluding computers and software, professional sports teams, and real estatedevelopment

One of the first products sold by Microsoft was the BASIC computerprogramming language Since then they have developed many other productsand many other programming languages The product you will learn in this set of

notes is called Visual C# The word Visual means you will build based applications that a user can see and interact with The term C#

Windows-(pronounced “cee sharp”) refers to the particular language used within the VisualC# environment This language was developed using pieces of other languagescalled C, C++ and Java Visual C# is one of the easiest programming languages

to learn Yet, even though it is easy to learn and to use, Visual C# can also beused to develop very powerful computer programs Visual C# provides asophisticated environment for building and testing Windows-based applications.You’ve used Windows-based applications before Microsoft’s programs likeWord, Excel, Internet Explorer and the windows that appear within theseapplications (to open and save files, to print files) are all Windows-basedapplications These applications are not written in Visual C# (they are written in

a language called C++), but they do demonstrate the functionality you can put inyour Visual C# applications

Trang 35

So, why learn Visual C#? There are several reasons for doing this First, ifyou know how to program, you will have a better understanding of just howcomputers work Second, writing programs is good exercise for your thinkingskills – you must be a very logical thinker to write computer programs Youmust also be something of a perfectionist – computers are not that smart andrequire exact, perfect instructions to do their jobs Third, computer programmersare in demand and make a lot of money And, last, writing computer programs isfun It’s rewarding to see your ideas for a certain computer program come to life

on the computer screen In these notes, you will learn how to use Microsoft’sVisual C# to write your own Windows-based applications You may not become

a billionaire like Bill and Paul, but hopefully you’ll have some fun learning avery valuable skill

Trang 36

Learning how to use Visual C# to write a computer program (like learninganything new) involves many steps, many new terms, and many new skills Wewill take it slow, describing each step, term, and skill in detail Before starting,

You have probably used all of these skills if you’ve ever used a wordprocessor, spreadsheet, or any other software on your computer If you think youlack any of these skills, ask someone for help They should be able to show youhow to do them in just a few minutes Actually, any time you feel stuck whiletrying to learn this material, never be afraid to ask someone for help We wereall beginners at one time and people really like helping you learn

Let’s get going And, as we said, we’re going to take it slow In this firstclass, we will learn how to get Visual C# started on a computer, how to load aprogram (or project) into Visual C#, how to run the program, how to stop theprogram, and how to exit from Visual C# It will be a good introduction to the

Trang 37

many new things we will learn in the classes to come.

Trang 38

We assume you have Visual C# installed and operational on your computer

If you don’t, you need to do this first Again, this might be a good place to askfor someone’s help if you need it Visual C# is available for free download fromMicrosoft

Visual C# is included as a part of Microsoft Visual Studio 2015 Community Edition Visual Studio includes not only Visual C#, but also Visual

C++ Express and Visual Basic Express All three languages use the samedevelopment environment Follow this link for complete instructions fordownloading and installing Visual Studio 2015 Community Edition on yourcomputer: https://www.visualstudio.com/products/free-developer-offers-vs

Trang 39

be familiar with how menus work from using other programs like word

processors and games Under the main menu is a Toolbar Here, little buttons

with pictures also allow us to control Visual C#, much like the main menu Ifyou put the mouse cursor over one of these buttons for a second or so, a little

‘tooltip’ will pop up and tell you what that particular button does - try it! Almostall Windows applications (spreadsheets, word processors, games) have toolbarsthat help us do different tasks This is the purpose of the Visual C# toolbar It

will help us do most of our tasks In the middle of the screen is the Start Page, contained in the Design Window This page has many helpful topics you might

be interested in pursuing as you learn more about Visual C# – especially note

Trang 40

At any time, your particular screen may look different than ours The VisualC# environment can be customized to an infinite number of possibilities Thismeans you can make things look anyway you want them to You can ‘dock’windows or ‘float’ windows You can move windows wherever you want or youcan completely delete windows And, different windows will appear at differenttimes As you become more experienced with Visual C#, you will learn waysyou want things to be We encourage you to try different things Try movingwindows Try docking and floating We won’t talk a lot about how to customizethe development environment (We will, however, always show you how to findthe particular window you need.)

Ngày đăng: 26/01/2023, 13:14