Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.

Slides:



Advertisements
Similar presentations
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Four Defining Your Own Classes.
Advertisements

CS0004: Introduction to Programming Visual Studio 2010 and Controls.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
1. Chapter 29 Creating Forms 3 Understanding Forms Word enables you to create fill-in forms to eliminate the need for storing pre-printed forms. Add.
Intro to Microsoft PowerPoint 2010 Public Computer Center, Moore Memorial Library, Greene, NY.
The Web Warrior Guide to Web Design Technologies
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 2 Stewart Blakeway FML 213
BlueJ: a very quick introduction. BlueJ BlueJ is an IDE (Interactive Development Environment). It includes –an editor, which you use to write your programs.
Fall 2007ACS-1903 BlueJ Ron McFadyen Lab 1: Using BlueJ at UofW The purpose of this lab is to give you some experience with BlueJ. Over the course of the.
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
C++ Classes in Depth. Topics Designing Your Own Classes Attributes and Behaviors Writing Classes in C++ Creating and Using Objects.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
13-Jul-15 BlueJ: A Very Quick Introduction. BlueJ BlueJ is an IDE (Integrated Development Environment). It includes an editor, which you use to write.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Programing App Inventor. Variable Declaration App Inventor: Declare Variables using the “Define Variable As” Block – Find the Blocks Editor (top-left),
Pasewark & Pasewark 1 Word Lesson 6 Working with Graphics Microsoft Office 2007: Introductory.
Concept of Computer Programming November 2, 2011.
Microsoft Office 2007: Introductory 1 Word Lesson 6 Working with Graphics Computer Applications 1.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Java: Chapter 1 Computer Systems Computer Programming II Aug
1 CSC 221: Computer Programming I Fall 2004 Objects and classes: a first pass  software objects, classes, object-oriented design  BlueJ IDE, compilation.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
Tutorial 6 Using Form Tools and Creating Custom Forms
® Microsoft Access 2010 Tutorial 6 Using Form Tools and Creating Custom Forms.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Java: Chapter 1 Computer Systems Computer Programming II.
Chapter 8: Writing Graphical User Interfaces
Creating a PowerPoint Presentation
CPSC150 Spring 2007 Dr. L. Lambert. CPSC150 Overview Syllabus Use Textbook, ask questions, extra thorough, I will post sections covered All information.
Java Classes Using Java Classes Introduction to UML.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Introduction to Java. 2 Textbook David J. Barnes & Michael Kölling Objects First with Java A Practical Introduction using BlueJ Fourth edition, Pearson.
A way to pull together related data A Shape Class would contain the following data: x, y, height, width Then associate methods with that data A Shape.
OBJECTS AND CLASSES CITS1001. Concepts for this lecture class; object; instance method; parameter; signature data type multiple instances; state method.
Chapter 1 Object Orientation: Objects and Classes.
CREATING A POWERPOINT PRESENTATION. Planning a presentation Create a presentation Rearrange and delete text and slides Add animations Add transitions.
PowerPoint Basics Tutorial 3: Graphics In this tutorial we’ll be looking at graphics, and the various types of illustrations that can be included in a.
Java is an object oriented programming language In this model of programming all entities are objects that have methods and fields Methods perform tasks.
Computer Information Technology – Section 4-12 Some text and examples used with permission from: Note: We not endorsing or promoting.
Introduction to programming in the Java programming language.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Introduction to Programming with RAPTOR
1 CSC 221: Computer Programming I Spring 2008 Objects and classes: a broad view  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Game Maker – Getting Started What is Game Maker?.
PowerPoint Basics Tutorial 3: Graphics In this tutorial we’ll be looking at graphics, and the various types of illustrations that can be included in a.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Introduction To Greenfoot
1 CSC 221: Computer Programming I Fall 2009 Objects and classes: a broad view  Scratch programming review  object-oriented design, software objects 
Installing Java on a Home machine For Windows Users: Download/Install: Go to downloads html.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Programming Logic and Design Seventh Edition
Working in the Forms Developer Environment
Flash Interface, Commands and Functions
Microsoft Word: Tables
CompSci 230 Software Construction
Chapter 4 Defining Instantiable Classes
Java Programming with BlueJ
The method invocation mechanism and the System Stack
Java objects: a first view
Java Programming with BlueJ Objectives
Presentation transcript:

Introduction to Programming with Java

Overview What are the tools we are using – What is Java? This is the language that you use to write your program – What is BlueJ? This is the editor in which you write your program Goal for the end of the year is to design and build a program of your own.

What are we doing today? Introduce some terms Get used to the environment Get our hands dirty and write some code to draw a creeper’s head

BlueJ IDE Basics Class Diagram: Lists the classes available in your program Object Bench: Shows which objects exists in the computer’s memory. A Class: Describes an object and what it can do. Compile Button: Translates human readable code into computer readable code. Compile Button: Translates human readable code into computer readable code.

Terms Objects – – Computer’s representation of a real world object or thing. It exists in the computer’s memory. – Example: Creeper, Skeleton, Sheep, Bow etc. Anything you can see in your world. Class – – Describes what an object is and what it can do. It is a blueprint for the object in the same way architectural plans describe a building. – Example: A creeper will be green, have two black eyes, explode, die, walk, etc. Each object is described by a different class.

Practice Classes A Picture Object

Practice Creating an Object 1.Right-click on the Picture class 2.Select new Picture() – FYI this is the constructor for a Picture object. 3.In the dialogue box type in creeperHead (with no spaces) 4.This will create a picture object that will eventually draw a picture of your creeper head. You will see a blank window called BlueJ Shapes Demo appear. 5.On your own: Create a new Quadrilateral object. (You can accept the default name. Once you have completed the task, you will see an new object in your object bench.)

Terms Method – Is an action that the object can perform. – The class describes how to perform the action. – Given the example below, the method name is makeVisible. – Example: void makeVisible() method describes how the object is to make itself visible. To perform the action, a programmer must invoke or call the method.

Practice Calling Methods 1.Right-click on the Quadrilateral object in the object bench 2.Select void makeVisible() 3.You will see a red square appear in the BlueJ Shapes Demo window. 4.On your own: move the object either up, down, left, or right. What methods enable you to do this?

Terms Parameter – Is input to your method so that it can do its job. – A value may or may not be required. – A value is required whenever you see words in between the parenthesis after the method name. – Example: If I want to change the color of my quadrilateral, I need to state which color I want to make my shape – in this case “green”.

Practice Calling Methods 1.Right-click on the Quadrilateral object 2.Select void changeColor(String newColor) – ( String newColor is the parameter) 3.A dialogue box appears. Type “green” in the dialogue box and click OK. (Note: you must type the quotes.) 4.On your own: change the height, width, or position of your object.

IDE Basics Summary So far the tutorial has familiarized you with the interactive components of the BlueJ IDE. – Creating Objects. – Calling methods with and without parameters. The problem is the your work is not saved and you are limited to what has been provided in the project. Next let’s write some code!

Terms Variable – is a named storage container that holds a specific type of data. – It must be declared before you can do anything with it. – Once the variable has been declared, you can place the object within the variable. – The variables creeperHead and creeperHead can hold only a Square ; the creeperHat only holds a Triangle. Quadrilateral leftCreeperEye Triangle creeperHat Objects Variables Quadrilateral creeperHead

Write a Variable Practice 1.Double-click the Picture class to open the source code editor. 2.Type private Quadrilateral head; after the class declaration 1 to declare the variable. 3.Type head = new Quadrilateral(); after the draw() method header 2 to initialize the variable 3. 4.Click the Compile button on the BlueJ main window. (2) Declare the variable. (3) Create the object and store it in the variable.

Invoking Methods At this point if you create a picture object nothing will happen. 1.In the source code editor type head.changeHeight(200); head.changeWidth(200); head.makeVisible(); 2. Compile your code. 3. Create a Picture object. You will see a large red square appear in the BlueJ Shapes Demo window. 4. On Your Own: Add code to the draw method to change the head object “green”. To view available methods: Open the Quadrilateral source code editor and switch to documentation view by clicking on the dropdown with “Source Code” in it.

Code Writing Summary A variable declaration reserves space in the computer’s memory to store an object. – It must be declared directly after the class declaration. A variable must be initialized in order to hold the object. You can invoke methods of an object by using the following template. ( ); All code must be written within a method definition.

Design Your Project Before starting any project – plan! Follow: – Understand: ask questions. – Design: on paper layout what you want to do. – Implement & Test: write the code and then test it. – Consider Alternatives: ask how to fix your code if it failed your test. Keep in mind the following: “Fail to plan; plan to fail” Create a sketch of what you are doing and/or a list of what you will need. It does not need to be perfect, it is just a starting point and it will change. – We need a head which is a green square; two eyes which are two black squares; a mouth …

Your First Project – Draw a Creeper’s Head Design: On a separate sheet of paper, draw a creeper’s head and face. You have already created its head. You will need additional objects in order to complete the picture. On the picture note: – Approximate size and location of the eyes and mouth. – Solve simple problems first. For example the mouth is complex so make the mouth just a simple rectangle first. Implement: In your code declare the necessary variables and then invoke the required methods to draw the remaining eyes and mouth. Remember your drawing and plans do not need to be perfect, it is just a starting point and it will change. There will be a lot of trial and error!

Summary This tutorial covered a tremendous amount of ground. You learned: – About the BlueJ IDE. – Basic Terminology that is essential to programming. – Write a simple program that drew the head of a creeper. At home you can continue practicing your coding skills by drawing other pictures and experimenting. Keep a spare copy of your project for safe keeping, then mess around with the code. If you mess something up – no worries because you have your spare from which you can make a new copy!