week 1 part 2 setting up eclipse to create a...

17
Object Oriented Programming Week 1 Part 2 Setting up Eclipse to Create a Class

Upload: others

Post on 14-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Object Oriented Programming

Week 1 Part 2Setting up Eclipse to Create a Class

Page 2: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 2

Setting up a Java Object using Eclipse

Page 3: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 3

Eclipse

● Eclipse is an IDE (Integrated DevelopmentEnvironment)– It provides and editor

– A build system and compiler

– A test system

– A Software Configuration System

– And more

● IDE simplify programming, once you learn touse them.

Page 4: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 4

Writing a Program in Eclipse

1.Create a Project

2.Inside the project create a class● Add the class to a package

3.Add the instance variables and methods to theclass.

● The IDE notifies you immediately if there are compilererrors

Page 5: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 5

Create a ProjectAdd a new

Java Project

Page 6: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 6

Name your Project

Give ita name

ClickFinish

Page 7: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 7

Now you have a project

Demoproject

Page 8: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 8

Add Class Name and Package

Package

Name

Finish

Page 9: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 9

Add a Class

1. Right click project2. Roll over New3. Select Class

Page 10: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 10

We have a class

Class Point inFolder src andPackage oop

Page 11: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 11

Setting up Eclipse to do Test Driven Development

Page 12: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 12

Eclipse and TDD

● Eclipse for Java is designed for TDD– JUnit is integrated into the Java development

environment

– You can run JUnit tests from the IDE

– You can access failing tests with a click of themouse

– Eclipse suggests solutions to failing tests

● But first you need to set up the tests

Page 13: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 13

New Source Folder for Tests

1. Right Click Project2. Select New3. Select Source Folder

Page 14: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 14

Give the folder a name

Name the new folder “test”

Click finish

Page 15: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 15

Make a New Junit Test

1. Right click new folder2. Select New3. Select Junit Test Case

Page 16: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 16

Name the test and add it to package

Name it “TestPoint”

Put it in the “oop” package

Page 17: Week 1 Part 2 Setting up Eclipse to Create a Classoo.nathanielgmartin.com/Wk01/w1-L2-IntroEclipseSetup.pdf · 2016-06-15 · Week 1 4 Writing a Program in Eclipse 1.Create a Project

Week 1 17

Add JUnit 4 to the build path

Click OK