18

Click here to load reader

CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

Embed Size (px)

Citation preview

Page 1: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 1

CI228 Tutorials

Page 2: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 2

BIO - Basic Input OutputInput of an integer number

The static method BIO.getInt() will read from thekeyboard an integer number typed by the user. This valuemust be assigned to a variable of type int.

int iDays = BIO.getInt(); //Whole number

Will input into the variable iDays an integer numbertyped by the user.

A program in Java to input a number of days and calculatethe number of weeks and days this represents.

class Main{ public static void main( String args[] ) { System.out.print( "#Input number of days " ); int iDays = BIO.getInt();

System.out.print( iDays ); System.out.print( " days is equal to " );

int weeks = iDays / 7; //Number of weeks System.out.print( weeks ); System.out.print( " week(s) " );

int days = iDays % 7; //Remaining days System.out.print( days ); System.out.println( " day(s) " ); }}

#Input number of days 1010 days is equal to 1 week(s) 3 day(s)

Page 3: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 3

The Charon system will ignore any line in your outputthat contains a #. Hence you can output any line(containing a # ) and it will be ignored when Charoncompares your answer with the expected answer.

The class BIO is automatically included when you useBlueJ or submit a program to Charon. If you want to usethis at home then you need to include the code for theclass BIO (see programs on web site) in your program.

Page 4: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 4

Summary of BIO

Static method call DescriptionBIO.getInt() Read a line and return as an int

the number that is containedwithin the line. If the number ismalformed then return 0.

BIO.getDouble() Read a line and return as adouble the number that iscontained within the line. If thenumber is malformed then return0.0.

BIO.getString() Read a line and return as aninstance of a String the charactersthat are contained within the line.Any leading or trailing whitespace characters will bepreserved.

BIO.eof() Returns true if the end of theinput has been reached otherwisefalse.

If during a read operation an attempt is made to read pastthe end of input (EOF) normally a warning message willbe printed and the program will terminate.

Page 5: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 5

Week #1 Tutorial Room Using an IDE

This tutorial is all about completing exercise 1.1 & 1.2using an IDE Integrated Development Environment.

PreparationYou need to work out on paper your Java solutions tocoursework exercises 1.1 & 1.2.

These exercises are to get you back into programconstruction as well as an introduction to the Charonsystem if you have not yet used this (Direct entrants)

If you are a direct entrant to Level 5, then do ask forhelp, if you are unsure about any of this work.

At the tutorial use an IDE to develop your programsbefore submitting the answer to the Charon system.

The IDE Eclipse is more advanced than BlueJ and willgive you many new features to manipulate your Javacode. It would be good to become familiar withEclipse during your study of CI228.

Remember when using Eclipse, you will need to createa class Main for the program and a class BIO for thecode of the Basic Input and Output methods. The codefor BIO is available on line in the programs for week 1.

Page 6: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 6

Week #2 Tutorial Room

If you are not sure about inheritance do ask at thetutorial.

Start to look at what is required for exercise 1.3. Sketchout an outline on paper what the classAccountBetter1 will contain.

When you implement an interface it is simply apromise to provide that method in the class togetherwith its body that you have to write.

The reason for using the interface Transfer is toguarantor that the class AccountBetter1 will providean implementation for the methods transferFromand transferTo.

AccountBetter1 extends Account implements transfer

Try out your code for AccountBetter1 using thetest program in the on-line notes. (Under programs atthe end of the web page)

Page 7: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 7

Week #3 Tutorial Room

This tutorial is all about exercises 1.3, 1.4 & 1.5 usingan Integrated Development Environment.

You should make sure that you are clear aboutinheritance and the use of interfaces in Java.

Exercises 1.3 is an example of the use of inheritance andthe use of an interface. Interfaces are covered in detail inlecture 3.

Classes/ Interfaces that need to be used:Main Note the test program provided, writes out the

result of calling methods in the class that you write.Charon will check that these are the correct result ofcalling these methods.

Account (See c/w description for code)

AccountBetter1 The class that you will create by inheriting from theclass Account & implementing the methods in theinterface Transfer,

Transfer An interface that AccountBetter1 implements.(See c/w description for code)

Page 8: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 8

Exercises 1.4 is a example of the use of inheritance and theuse of an interface.

Classes/ Interfaces that need to be used:Main Note the test program provided, writes out the

result of calling methods in the class that you write.Charon will check that these are the correct result ofcalling these methods.

Account (See c/w description for code)

AccountBetter1 The class that you created by inheriting from theclass Account in exercise 1.3

AccountBetter2 The class that you construct for this part of thecoursework. This class inherits from the classAccountBetter1 that you created for exercise 2.1.

Transfer An interface that AccountBetter1 implements.(See c/w description for code)

Interest An interface that AccountBetter2 implements.(See c/w description for code)

Page 9: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 9

Exercises 1.5 is an example of the use of overriding anexisting method when inheriting.

Classes/ Interfaces that need to be used:Main Note the test program provided, writes out the

result of calling methods in the class that you write.Charon will check that these are the correct result ofcalling these methods.

Account (See c/w description for code)

AccountBetter1 The class that you created by inheriting from theclass Account.

AccountBetter2 The class that you created by inheriting from theclass AccountBetter1.

StudentAccount The class that you construct for this part of thecoursework. This class inherits from the classAccountBetter2 that you created for exercise 1.4

Transfer An interface that AccountBetter1 implements.(See c/w description for code)

Interest An interface that AccountBetter2 implements.(See c/w description for code)

Page 10: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 10

Week #4 Tutorial Room

Sorting out those last problems with exercises 1.4 & 1.5

Making sure that you understand the description ofthe CatShop in this week 4's notes.

Make sure that you can compile and run the CatShopsystem.

Important you will need to set up the Derby DataBase.See the course notes for CI228 for how to do this.

Make sure that you understand what is required forcoursework 2.1 & 2.2.

Page 11: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 11

Week #5 Tutorial Room The Catalogue shop

Working on exercise 2.1 and making sure that youunderstand how to incorporate BetterBasket into theCatshop system.

Classes that you need for 2.1:

Basket The code for this class in the CatShop system inthe package catalogue.

Product The code for this class in the CatShop system inthe package catalogue.

BetterBasket The class that you will create by inheriting fromBasket.

Put this in the package catalogue. The first lineof the class should be: 'package catalogue'.

ImportantThe code for Basket, BetterBasket and Productshow that they belong to the package catalogue. If youare testing your classes in isolation then you will need totake account of this in any testing.

Page 12: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 12

Week #6

Reading week / Catchup week

A chance to catch up or read ahead.No tutorial this week.

Information correct at time of printing. However, docheck for any last minute changes.

Page 13: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 13

Week #7 Tutorial Room The Catalogue shop

Completing exercise 2.1Compleating your critique of your work.

Thinking about the extension you will implement tothe CatShop system. Discuss this with your tutor inthe tutorial group.

Page 14: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 14

Week #8 Tutorial Room The Catalogue shop

Working on your extension to the CatShop system.Working on your critique of your work.

Prelimary reserach on your report.

Page 15: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 15

Week #9 Tutorial Room The Catalogue shop

Planning your report.

You may wish to run through your ideas with yourtutor in the tutorial.

Page 16: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 16

Week #10 Tutorial Room The Catalogue shop

Complete a draft of your report.

You may wish to run through your ideas with yourtutor in the tutorial.

Page 17: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 17

Week #11 Tutorial Room The Catalogue shop

Resolving any issues with your coursework. Finishingthe extension to the CatShop system. Final polishing ofyour report.

Page 18: CI228 Tutorials - cem.brighton.ac.uk · Week #1 Tutorial Room Using an IDE This tutorial is all about completing exercise 1.1 & 1.2 ... The IDE Eclipse is more advanced than BlueJ

CI228 TTTTuuuuttttoooorrrriiiiaaaallllssss

© M A Smith University of Brighton September 13, 2016 Page 18

Week #12 Tutorial Room

Demonstration of the CatShop program