rdhc1330's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
130 (0.13 per day)
Joined:
01-August 11
Profile Views:
1,542
Last Active:
User is offline Oct 23 2012 03:36 PM
Currently:
Offline

Previous Fields

Country:
NZ
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   rdhc1330 Just joined! :)

Posts I've Made

  1. In Topic: problem with 3d rendering engine

    Posted 23 Oct 2012

    I get what you're saying I just don't quite understand how to execute this and where to put the thread.sleep()? If not in the constructor then where as it has to load in the code?

    View Postpbl, on 23 October 2012 - 06:59 PM, said:

    Does not make sense at all to actually execute updating code and Thread.sleep() in a constructor

    You constructor will not exit until all this code is finish and constructor terminated
    The constructor has to finish before the created object can be add() to a container
  2. In Topic: Problem: Not getting output

    Posted 12 Aug 2012

    That's great, thank you so much, was wondering how I was going to do that! You print all of the data in the function where I just want it to print only courses with no id numbers... how do I get it to do that? I have tried
     if(! id_num ) 
    
    on the void print function? should look like this :S =

    Quote

    "Courses with no students enrolled:
    157112, System-Analysis, Credits 12, 0 students"
  3. In Topic: Problem: Not getting output

    Posted 12 Aug 2012

    Other txt file!
  4. In Topic: Question: How to read from a file and print only NO option.

    Posted 7 Aug 2012

    Sorry Jim! OK so that part of the code is working fine now... Here's the code in its entirety:

    //---------------------------------------------------------------------------
    #include <vcl.h>
    #include <tchar.h>
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    
    using namespace std;
    
    const char STUDENT[] = "C:\\students.txt";
    const char COURSES[] = "C:\\courses.txt";
    
    class Student
    {
    public:
    	Student();
    	Student(char firstName[] , char secondName[] , int id , char enrld);
    	~Student();
    	int getIDNumber();
    	char* getFirstName();
    	char* getSecondName();
    	char getEnrolled();
    	void setIDNumber( int id );
    	void setFirstName( char firstName[] );
    	void setSecondName( char secondName[] );
    	void setEnrolled( char enrolled );
    	void print();
    private:
    	char first_name[ 16 ];
    	char second_name[ 16 ];
    	int id_number;
    	char enrolled;
    };
    
    class Course
    {
    public:
    	int course_identifier;
    	char course_name[ 32 ];
    	int credits;
    	int id_number;
    };
    
    Student :: Student()
    {
    
    }
    
    Student :: ~Student()
    {
    
    }
    
    Student :: Student( char firstName[], char secondName[], int id, char enrld )
    {
    	strcpy( first_name , firstName );
    	strcpy(second_name , secondName );
    	id_number = id;
    	enrolled = enrld;
    }
    
    int Student :: getIDNumber()
    {
    	return id_number;
    }
    
    char Student :: getEnrolled()
    {
    	return enrolled;
    }
    
    char* Student :: getFirstName()
    {
    	return first_name;
    }
    
    char* Student :: getSecondName()
    {
    	return second_name;
    }
    
    void Student :: setIDNumber( int id )
    {
    	id_number = id;
    }
    
    void Student :: setEnrolled( char enrolled )
    {
    	this -> enrolled = enrolled;
    }
    
    void Student :: setFirstName( char firstName[] )
    {
    	strcpy( first_name , firstName );
    }
    
    void Student :: setSecondName( char secondName[] )
    {
    	strcpy( second_name , secondName );
    }
    
    void Student :: print()
    {
    	if( enrolled == 'N' )
    	{
    		cout << "   " << second_name << ", " << first_name << ": ID "
    		<< id_number << ", paid fees " << enrolled;
    	}
    }
    
    bool readStudents( Student[] , int& );
    void printAllStudents( Student[], int );
    //---------------------------------------------------------------------------
    int _tmain(int argc, _TCHAR* argv[])
    {
    	Student students[ 1024 ];
    	int nrOfStudents = 0;
    
    	cout << "************************" << endl;
    	cout << "* 159.234 Assignment 2 *" << endl;
    	cout << "*   05155932 Syms C.   *" << endl;
    	cout << "*       S2 2012        *" << endl;
    	cout << "************************" << endl << endl;
    
    	cout << "Students not enrolled in any paper: " << endl;
    
    	if( !readStudents ( students , nrOfStudents ) )
    		return 1;
    
    	printAllStudents( students , nrOfStudents );
    
    	getch();
    	return 0;
    }
    //---------------------------------------------------------------------------
    bool readStudents( Student students[] , int &nrOfStudents)
    {
    	ifstream read;
    	read.open(STUDENT);
    
    	if (! read.is_open())
    	{
    		return false;
    	}
    
    	int nr = 0;
    
    	char fName[16];
    	char sName[16];
    	char enrolled;
    	int id;
    
    	read >> nr;
    	while (! read.eof() && nrOfStudents != nr)
    	{
    		read >> fName;
    		read >> sName;
    		read >> id;
    		read >> enrolled;
    
    		students[ nrOfStudents ] = Student( fName , sName , id , enrolled );
    
    		nrOfStudents++;
    	}
    
    	read.close();
    	return true;
    }
    //---------------------------------------------------------------------------
    void printAllStudents( Student students[] , int nrOfStudents )
    {
    	for (int i = 0; i < nrOfStudents; i++)
    	{
    		students[i].print();
    	}
    }
    //---------------------------------------------------------------------------
    
    


    The required output is supposed to be like:

    Quote

    Students not enrolled in any paper:
    Blake, James: ID 7177323, paid fees N


    It is doing this now after I changed the above piece of code to include the if statement.

    Now I just need the code to read through the courses text file and read to print this:

    Quote

    Courses with no students enrolled: 157314, System-Analysis, credits 12, 0 students


    I think I'm on the right track here, my code feels messy but it's the first time I've had a real go at classes so if there's anything else you could recommend then that would be fantastico.
  5. In Topic: Question: How to read from a file and print only NO option.

    Posted 7 Aug 2012

    [quote name='rdhc1330' date='07 August 2012 - 05:25 PM' timestamp='1344385550' post='1680461']
    
    void Student :: print()
    {
    	cout << "First Name: " << first_name << endl;
    	cout << "Second Name: " << second_name << endl;
    	cout << "ID: " << id_number << endl;
    	cout << "Enrolled: " << enrolled << endl;
    
    	cout << endl;
    }
    
    


    Has been changed to:

    void Student :: print()
    {
    	if( enrolled == 'N' )
    	{
    		cout << "\t" << second_name << ", " << first_name << ": ID "
    		<< id_number << ", paid fees " << enrolled;
    	}
    	cout << endl;
    }
    
    

My Information

Member Title:
D.I.C Head
Age:
17 years old
Birthday:
June 26, 1996
Gender:
Location:
New Zealand
Full Name:
Charles
Years Programming:
1
Programming Languages:
C++, Ruby on Rails

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

Page 1 of 1
  1. Photo

    jesicalbaby Icon

    16 Sep 2013 - 14:25
    Hello
    My name is Miss jesical,
    i saw your profile today
    and,i fill more interest to contact you ,
    i will like you to please send me
    an email via (jesicalduncan22@yahoo.com)
    for me to send you my picture
    jesicalduncan22@yahoo.com
  2. Photo

    hulla Icon

    22 Sep 2011 - 04:35
    Oh I see.
  3. Photo

    hulla Icon

    21 Sep 2011 - 23:41
    Hey. :) What does rdhc mean?
Page 1 of 1