PRG 2X2: Files

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

PRG 2X2

FILES

www.belgiumcampus.ac.za
Learning objectives

In this presentation we will be looking at:


• FileHandler

2
www.belgiumcampus.ac.za
Class
• A class is like a blueprint of a specific object. In the real world, every object has some
color, shape, and functionalities - for example, the luxury car Ferrari. Ferrari is an
• object of the luxury car type. The luxury car is a class that indicates some characteristics
like speed, color, shape, interior, etc. So any company that makes a car that meets those
requirements is an object of the luxury car type. For example, every single car of BMW,
Lamborghini, Cadillac are an object of the class called 'Luxury Car'. Here, 'Luxury Car' is a
class, and every single physical car is an object of the luxury car class.
• Likewise, in object-oriented programming, a class defines some properties, fields, events,
methods, etc. A class defines the kinds of data and the functionality their objects will have.
• A class enables you to create your custom types by grouping variables of other types,
methods, and events.

3
www.belgiumcampus.ac.za
Advantages of Class
• A class enables you to create your custom types by grouping variables
of other types, methods, and events
• You cannot use the new keyword to create a variable of the
class type.
• With a non static class you can instantiate two (or more) instances 

4
www.belgiumcampus.ac.za
FileHandler?
• A file handler is a class that we create to do all the file methods such
as Writing and Reading from a data source in this instance we are
dealing with textfiles .
• The class followers all the rules of the basic class syntax.
• We create Filehandlers so that our code can be organized in different
class.
• The same Advantages of a class are the ones that are being utilized
when we design a FileHandler .

5
www.belgiumcampus.ac.za
Need of FileHandler
• All the code is in one class

6
www.belgiumcampus.ac.za
Using a FileHandler
• We created a class called FileHandler which will contain our two
methods to Write and Read to and from a textfile.

7
www.belgiumcampus.ac.za
THANK YOU

/belgiumcampusSA

#Belgium Campus

info@belgiumcampus.ac.za +27 10 593 53 68 /belgiumcampus

8
www.belgiumcampus.ac.za

You might also like