Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes.

Similar presentations


Presentation on theme: "1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes."— Presentation transcript:

1 1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes

2 2 File I/O b Include fstream to enable file I/O b Declare an object of type “ifstream” if reading from a file b Declare an object of type “ofstream” if writing to a file b Report error if file open fails

3 3 File I/O b Use get and put to handle characters b Use >> and > and << to handle numbers and strings b Check for End of File with eof() member function of stream object b Close files after use

4 4 Lab Exercise 13-A for File I/O b b Read the text file provided as “sample.txt” and write a program that allows a user to select one function out of the following: Changing all letters to uppercase Changing first letter of every word to uppercase #include and toupper() function)(Use #include and toupper() function)

5 5 Handling Classes b You have to plan for implementing a program with classes b Decide about the structure of the class, its private and public members b Then define the class in a header file and implement its functions in an implementation file b Develop the client code later to use the objects that belong to this class

6 6 Lab Exercise 13-B for Handling Classes b A vending machine contains fruit juices and soft drinks. It can have a maximum of 10 apple juice cans, 10 orange juice cans, 10 mixed juice cans, 10 pepsi cans and 10 sprite cans. Users can buy one can at a time and more items can be added to the machine

7 7 Lab Exercise 13-B b Develop a program that models this vending machine as an object. It should have all items as private data items and buy/add functions as public functions. There should be another public function show() that shows (prints) all items and their current quantity available.


Download ppt "1 Lab Session-XIII CSIT121 Fall 2000 b Lab Exercise13-A for Handling Files b Lab Exercise 13-B for Using Classes."

Similar presentations


Ads by Google