Jump to content
encik pot pet

Mari Buat Soalan Assignment

Recommended Posts

semalam aku dapat pm dari seorang student, nanti kita buat sama2 sebagai latihan lepas due date dia. :)

salam..sy ni budak it yg tak amik foundation ..skip sbb ade stpm...tapi sy wajib amik object oriented programming.....jadi ni asemen yg perlu basic c++....sy da buntu..help me...kalau leh add la kat [censored] (ym)...ni soklannye...tolongla sy

tolong la bagi coding paling simple tuk sy

..............++++++++++++++++++++++++++++++++++++++++++++++

+++++++................

Mongolian College in Ulaanbaatar intends to exhibit the new books they have recently acquired during the college’s open day. The new books are classified under text, journal and report. The college has decided to produce a simple database for these books, so that when the visitor keys in the record number, the book title, classification (i.e. text, journal or report), author’s name, publisher and a brief comment will pop up on the computer screen.

Task (a):

You are the programmer of Mongolian College and you are required to write the database in object-oriented code and illustrate clearly the features of an object-oriented program.

You may take title, classification, author and publisher to be member data of a defined class and comment to be a member function of the defined class. You may also (though not essential) include additional member data or member functions, in order to further illustrate the features of an object-oriented program.

C++ is to be used for writing the program.

Edited by zeph

Share this post


Link to post
Share on other sites

cik zeph...jgnla forwardkan soklan ni..malu saye....xleh delete ke..kantoi la pulak nnt...=P

sapa soh mengaku. dia tak kasi pun ID ko :lol:

Share this post


Link to post
Share on other sites

mane boleh tanya soalan assigment kat sini..

yang ko ngaku nape..

aku rasa jap lagi kene `tembak` la ko.

tapi aku tatau la status ko sebagai `learning` jadi pelindung.

Share this post


Link to post
Share on other sites

ish2.. kenapa la panggil i 'cik'. terasa i. awwww. kang i lenyek kepala u. panggil la i, Yang Berkhidmat (YB).

anyway, code awak tu mmg ntah ape2 ntah. mula2 sekali aku nak sekeh kepala orang yg ajar ko pakai iostream.h tu. bullschildt!!

cara yg betul, #include<iostream>, tanpa .h

utk tidak memblurkan anda tu, awak tengok camner orang lain buat class.

http://www.cplusplus.com/doc/tutorial/classes.html

http://www.cprogramming.com/tutorial/lesson12.html

http://forum.putera.com/tanya/index.php?showtopic=26408

Share this post


Link to post
Share on other sites

gunnergirlz, kod awak dah ada iras2 OOP, tapi kenapa function/method ada dalam main()?

kelebihan OOP ialah reusability, tapi kod awak kat atas tak mencerminkan keaadaan yg sepatutnya. bila function/method ada dalam main, kalau awak nak guna lain kali, terpaksa la copy and paste balik kod2 tersebut.

Share this post


Link to post
Share on other sites

yr r mod....masa aku blajar c++ ni kat IKM n kat UNISEL....lecturer aku pun suruh letak iostream.h

kalau x letak xpe ker r.

mmg oop pun...=P

belasah je...asal kan leh run..=P...

pagi ni nak anta...=]....

so.delete kan je thread ni..=]

mencemarkan alam aje.....nnti bleh pulak dak2 baru belajo anto thread same cam kite...sbb terpengaruh ngan thread"mari buat soalan 'asemen'"...=P

dah2...kite enjoy...=P

kalau htr pada member xpe kot.btul x mod.xyah bukak thread kat sini.msj je kat member.

Share this post


Link to post
Share on other sites

mmg oop pun...=P

belasah je...asal kan leh run..=P...

pagi ni nak anta...=]....

so.delete kan je thread ni..=]

mencemarkan alam aje.....nnti bleh pulak dak2 baru belajo anto thread same cam kite...sbb terpengaruh ngan thread"mari buat soalan 'asemen'"...=P

dah2...kite enjoy...=P

utk makluman cik gunnerz, saya dah modify soalan di atas dan saya takkan delete thread ni sebab mungkin org lain boleh manfaat dari thread ni (soalan yg dibagi oleh lecturer awak bagus utk pembelajaran). lagipun saya belum submit apa2 jenis codes di atas. oleh itu, takde sebab lecturer cik gunnerz nak tolak markah sebab meniru.

yr r mod....masa aku blajar c++ ni kat IKM n kat UNISEL....lecturer aku pun suruh letak iostream.h

lecturer awak pun ketinggalan zaman dan tak ikut standard semasa. dia rujuk buku lama, iaitu buku yg dikeluar sebelum tahun 2000 dimana pada tahun 1998, standard baru telah diperkenalkan.

maklumat lanjut, http://www.research.att.com/~bs/C++.html dan kalau boleh sila la baca buku The C++ Programming Language

(Third Edition or Special Edition) oleh Bjarne Stroustrup kalau betul2 nak jadi programmer c++ :)

Share this post


Link to post
Share on other sites

sebab aku terasa rajin sikit tadi, aku try la buat program ni mengikut kehendak soalan,

#include<iostream>
#include<string>
#include<vector>
using namespace std;

class Book
{
private:
    vector<string> title;
    vector<string> author;
    vector<string> publisher;
    vector<string> isbn_no;
    vector<int> class_no;
//  char nama_file[50];

public:
    void insert(void);
    void search(void);

//  akan dibuat kemudian
//  void load(char* nama_file);
//  void save(char* nama_file);
};

// dapatkan maklumat dari pengguna
void Book::insert()
{
    string s;
    int i;

    cout << "Masukkan tajuk buku: ";
    cin >> s;
    title.push_back(s);
    cout << "Masukkan nama penulis: ";
    cin >> s;
    author.push_back(s);
    cout << "Masukkan nama syarikat penerbit: ";
    cin >> s;
    publisher.push_back(s);
    cout << "Masukkan no isbn ";
    cin >> s;
    isbn_no.push_back(s);
    cout << "Masukkan kod bahan (teks = 0, jurnal = 1, laporan = 2: ";
    cin >> i;
    class_no.push_back(i);
}

//buat fungsi carian dari 'pengkalan data'
void Book::search(void)
{
    int id;
    cout << "Masukkan no record yg hendak dicari (bermula dgn no 0): ";
    cin >> id;

    // print result based on vector index
    cout << "Tajuk buku: "<< title[id] << " Nama Penulis: " << author[id] << endl;
    cout << "Penerbit: "<< publisher[id] << " ISBN Number: " << isbn_no[id] << endl;
    cout << "Jenis Penerbitan: ";

    //print publication types
    string s;
    switch (id)
    {
    case 0:
        s = "Teks";
        break;
    case 1:
        s = "Jurnal";
        break;
    case 2:
        s = "Laporan";
        break;
    default:
        s = "popantek";
    }
    cout << s;
    cout << "\n\nSila tekan 1 untuk kembali ke menu: ";

    // to stop programming running
    int temp;
    cin >> temp;
}

int main()
{
    //object declared as z
    Book z;

    //infinite loop for data entry/display
    for (;;)
    {
        system("cls");
        cout<<"\n**********************************";
        cout<<"\n* WELCOME TO SYSTEMATIC COLLEGES *";
        cout<<"\n**********************************";
        cout<<endl;
        cout<<"\n\n PLEASE MAKE A CHOICE:";
        cout<<"\n ---------------------";
        cout<<endl;
        cout<<"\n +++++";
        cout<<"\n MENU";
        cout<<"\n +++++";
        cout<<endl;
        cout<<"\n 1. Key in Material";
        cout<<"\n 2. Search Record";
        cout<<"\n 3. Exit";
        cout<<"\n\nYOUR SELECTION: ";
        int x;
        cin >> x;

        switch (x)
        {
        case 1:
            z.insert();
            break;
        case 2:
            z.search();
            break;
        case 3:
            return 0;
            break;
        default:
            cout<< "salah masuk lah";
        }
    }

    return 0;
}

suntingan:

amaran, kod di atas tidak menepati ciri2 OOP sepenuhnya.

Edited by zeph

Share this post


Link to post
Share on other sites

aku baru blaja c language...

btw... x byk beza pn ngan c language...

kalo c language pki printf ngan scanf

ohoho..

hamba pn ader soklan asemen ni....

huhu~

Share this post


Link to post
Share on other sites

rase2 code yg en zeph kasi tu tersgt rumit lebey2 lg kat beginner..nway time memule blajar programming ni mmg sakit kepala la..last2 sronok sbb da tau camner nk wat..=P..siap ade project lg kena siapkn..

Share this post


Link to post
Share on other sites

Wei Zeph,

Camana ko wat bile kite enter 1 dia gi balik kat menu utama?

Kod bahagian mana yang buat fungsi tu?

Emmm, bila kita tutup program tu...data yang kita isi tu ada lagi tak?(disave di sesuatu tempat.

atau akn hilang?)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...