GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 26-Sep-2006, 00:48
mrdell_06 mrdell_06 is offline
New Member
 
Join Date: Feb 2006
Posts: 4
mrdell_06 is an unknown quantity at this point
Wink

C++ object oriented programming & file processing


can anybody out there help me to do this program??
your kindly heart is appreciated...!!!!
thanks a lot...


WXES1111: PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING
SEM 1, 2006/2007
GROUP PROJECT 2

This problem is intended to be solved in a closed-lab session with your selected group member (2 persons). The problem is divided into FOUR parts: -

1. Lab Objectives
2. Description of the problem
3. Some examples of the menus
4. Problem-Solving Tips


Lab Objectives
This lab was designed to test your problem-solving skills and to reinforce your programming concepts from WXES1108 till WXES1111. In this lab, you will practice how to build real-life applications using the concepts learnt in object-oriented programming and in C++ file processing. It is crucial that you go through the software process life cycle, which is: -

• understanding the problem given
• analyzing and defining the requirements
• defining your analysis model, e.g. What are the text files that your require? What are the classes that you require to solve this problem? etc
• designing your solution, using either pseudo-code or flow chart
• coding your solution
• testing your solution


Description of the Problem

DVD Rental Shop System

You are a programmer working for XYZ Computing Network. You were assigned by your boss to build a simple C++ system for a client’s DVD Rental Shop. The DVD Rental Shop is owned by Encik Zuhaizy.

In order to obtain the requirements of the system that needs to be built, you interviewed Encik Zuhaizy in order to gather the functions that he wants the system to have. After the interview session, you made a list of the system requirements, as shown below: -

• Encik Zuhaizy would like to be able to enter information on new DVD titles that his shop has purchased, along with the number of copies for each DVD. An example of this information is given below: -
DVD Title : SHREK 2
Genre : Comedy
No. of copies : 5

• Encik Zuhaizy would like to display the list of DVD titles that is currently in his stock. He wants this information in a table format, as shown below: -
DVD Title No. of Copies
1. SHREK 2 5
2. THE INCREDIBLES 4
etc..

• Encik Zuhaizy would also like to be able to display the DVD titles under the same genre. For example: -
Genre: Comedy
DVD Titles: SHREK 2
THE INCREDIBLES
SHREK 1

• Encik Zuhaizy would also like to be able to display the current number of DVD copies in stock. For example: -
DVD Title: SHREK 2
No of copies (total): 5
No of copies (in stock): 3

• Encik Zuhaizy would like to use the system to record a customer’s loan of a DVD. Before a customer can loan a DVD, Encik Zuhaizy needs to first register the customer into the system. The information that is required for each customer is given below: -
Name: Abu Bakar bin Kasim Selamat
IC No: 679987-08-6632
Address: NO 16, Jalan Seta Kasih 3, Taman Seri Setia, 50603, Kuala Lumpur
Tel. no: 012-111222

• Once a customer has been registered, Encik Zuhaizy can now enter the DVD rental that the customer has requested. This process involves checking whether the DVD title is currently in stock. If there is a copy, then the customer may rent the DVD at RM3 per copy. If there are no copies left, an error message will be displayed showing that the shop currently has no copies of the DVD. The information needed for this transaction are: -
DVD Title : SHREK 2
IC No. : 679987-08-6632
Rental Date : 22 November 2004
Due Date : 27 November 2004

The list that you have made above is the requirements that you need to have in your system. But you may add other additional features into your system, as needed, such as displaying the list of registered customer, displaying the DVD titles that a customer has rented etc.


Some examples of the menu: -

ZUHAIZY DVD RENTAL SHOP
====== Main Menu =========
1. CUSTOMER
2. DVD
3. RENTAL
4. EXIT

Enter your choice (1-4): 1


ZUHAIZY DVD RENTAL SHOP
===== Customer Menu ======
1. ADD NEW CUSTOMER
2. DELETE CUSTOMER
3. DISPLAY CUSTOMER INFORMATION
4. DISPLAY ALL CUSTOMER
5. EXIT

Enter your choice (1-4):


Problem-Solving Tips

1. In order to ensure that your system is able to perform the necessary functions, you need to use C++ file processing. You need 3 test files: -
o A file to store customer’s information
o A file to store the DVD information
o A file to store the customer’s rental information

2. Use the example given below, to aid to in implementing file processing.

CPP / C++ / C Code:
/*A simple example to show how to use an object-oriented approach
  to manage data on the name of a person. The list of names is stored
  in a text file, named name.txt*/

#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <stdlib.h>

class Name {
	char first[10];
	char last[10];
public:
	Name() { strcpy(first, "unknown"); strcpy(last, "unknown"); }
	void setData(char f[], char l[]) { strcpy(first, f); strcpy(last, l); }
	void display() {cout<<first<<" "<<last<<endl; }
	char *getFirst() { return first; }
	char *getLast() { return last; }
};

void main() {
	//create temporary strings to store the first and last name read from the file
	char temp1[10], temp2[10];
	char sentence[10];
	
	//create an array of Name object to store the names in the file
	Name array[10];
	int bil=0;//counter to count the number of names in file

	fstream file("name.txt", ios::in | ios::out);

	if (!file){
		cout<<"File cannot be opened!\n";
		exit(1);
	}

	cout<<"The contents of the file:\n";
	cout<<"-------------------------\n";
	do{
		file.getline(temp1, 10, '\n');//read from the file & store the values
		file.getline(temp2, 10, '\n');//in the temporary strings
		array[bil].setData(temp1, temp2); //assigning the values of the data read 
//to the private data of the class
		bil++; //the number of names read
	}while (!file.eof());
	
	cout<<"\nThe contents of the file is: \n";
	for (int i=0; i<bil; i++) //displaying the contents of the file
		array[i].display();

	cout<<endl<<endl<<"Input data to be inserted:\n"; //add another name
	cout<<"------------------\n";
	cout<<"First and last name: ";
	cin>>temp1>>temp2;
	array[bil].setData(temp1, temp2);
	bil++;

	file.clear();//copy back the list of names into the file
	file.seekp(0);
	for (i=0; i<bil; i++)
	{
		file<<array[i].getFirst()<<endl;
		
		if (i == bil - 1)
			file<<array[i].getLast();
		else
			file<<array[i].getLast()<<endl;
	}

//displaying the new content of the file
	cout<<endl<<endl<<"The new contents of the file:\n";
	cout<<"-----------------------------\n";
	
	file.clear();
	file.seekg(0);
	do{
		file.getline(sentence, 10, '\n');
		cout<<sentence<<endl;
	}while (!file.eof());

	cout<<endl;
	file.close();
}

The text file: name.txt

Timmy
Rush
Venesa
Paradise
Britney
Spears
Ronald
McDonald
Attached Files
File Type: doc WXES1111Group02.doc (60.0 KB, 28 views)
Last edited by LuciWiz : 26-Sep-2006 at 05:56. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 26-Sep-2006, 05:57
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,032
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: C++ object oriented programming & file processing


Senior members might not reply to this thread if you:
  • used "Please help", "C problem" or something equally vague as the title for your thread.
  • included example code in your message and not use the syntax highlighting [c] tags.
  • did not describe the problem accurately or include the error message (if any).
  • tried to get your homework assignment solved by someone else (and did not show your attempts at solving the problem)
The guidelines for posting can be found here.

We encourage you to post again once you've done that.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 04-Oct-2006, 12:02
CRoswell CRoswell is offline
New Member
 
Join Date: Oct 2006
Posts: 8
CRoswell is on a distinguished road

Re: C++ object oriented programming & file processing


Or at least offer some money to do the homework, come on!

lol, jk.

Seriously, do your own homework, otherwise you'll bomb on the tests and if you do manage to struggle through your degree, it wont be worth much.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
Object Oriented Programming? jake_jeckel C++ Forum 8 30-Oct-2005 13:25
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 16:13
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:35.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.