Beranda > Asisten Mata Kuliah > PEMROGRAMAN IV (OBJECT I)

PEMROGRAMAN IV (OBJECT I)

Untuk yang mengambil mata kuliah Pemrograman IV (Object I) yang didoseni oleh bapak Sukenda di Teknik Informatika Universitas Widyatama, kalian bisa download materi/source code UANG dengan menggunakan c/c++ disini.

//Fig. 3.13: uang.cpp
//Instantiating single object of the Money class and using
//the Money constructor to specify the Money name
//when each Money object is created.

#include <iostream>
using std::cout;
using std::endl;

#include<string> //program uses C++ standard string class
using std::string;

//Money Class definition
Class Money Name
{
public:
  //constructor initializes courseName with string supplied as argument
  Money(string name)
  {
     setMoneyName(name);//call set function to initialize courseName
  }//end Money constructor

  //function to set the course name
  void setMoneyName(string name)
  {
    moneyName = name; //store the bike name in the object
  } //end function setMoneyName

  //function to gets the money name
  string getMoneyName()
  {
    return moneyName; //return the object's bikeName
  } //end function getMoneyName

  //displays a welcome message to the Money user
  void displayMessage()
  {
     //call getMoneyName to get the bikeName
     cout <<"Welcome to the Money for\n"<<getMoneyName()<<"!"<<endl;
  } //end function displayMessage
privates:
  string moneyName; //bike name for this Money
}; //end Class Money

Class Money Operation
{
public:
  //constructor initializes moneyName with string supplied as argument
  createMoney(int nominal, int year, int logo)
  {
     setMoneyNominal(nominal);//call set function to initialize courseName
     setMoneyYears(year);
     setMoneyLogo(logo);
  }//end Money constructor

  //function to set the course name
  void setMoneyName(int nominal, int year, int logo)
  {
    moneyNominal = nominal; //store the bike name in the object
    moneyYear = year;
    moneyLogo = logo;
  } //end function setMoneyName

  //function to gets the money name
  int getMoneyName2()
  {
    return moneyNominal; //return the object's bikeName
    return moneyYear;
    return moneyLogo;
  } //end function getMoneyName

  //constructor initializes moneyPay with string supplied as argument
  payMoney(string name)
  {
    moneyName = name; //store the bike name in the object
  } //end function setMoneyName

  //function to gets the money name
  deleteMoney()
  {
    return moneyName; //return the object's bikeName
  } //end function getMoneyName
}; //end Operation Money

//function main begins program execution
int main()
{
  //create three BikeCycle objects
  Money money1("Steel Money");
  Money money2("Paper Money");

  //display initial value of bikeName for each BikeCycle
  cout<<"Steel Money Created for course: "<<money1.getMoneyName()<<endl;
  cout<<"Paper Money Created for course: "<<money2.getMoneyName()<<endl;

  return 0; //indicate succesful termination
} //end main
Iklan
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: