PDA

View Full Version : class



melina
چهارشنبه 05 بهمن 1384, 16:39 عصر
create a class called complex for performing arithmetic with complex numbers
write a program to test your class
complex numbers have the form
realpart + imaginarypart *i where i is radical -1
use double variables to represent the private data of the class. provide a constructor that enables an object of this class to be initializers when it is declared
the constructor should contion default values in case no initializers are provided.provide public member functions for each of the following: a) Adding two complex numbers :the real parts are added together and the imaginary parts are added together
b) subtracting two complex numbers: the real part of the right operand is subtracted from the real part of the left operand , and the imaginary part of the right operand is subtracted form the imaginary part of the left operand
c) printing complex numbers in the from (a,b) , where a is the real part and b is the imaginary part

اَرژنگ
چهارشنبه 05 بهمن 1384, 17:30 عصر
1_Change youe topic header
2_Change the language you ask questions here, only farsi questions allowed here
3_Change you script, you can use http://fingilish.com to type in farsi script using english keyboard
4_Send your post to proper sub forum. I cant even tell what language this is suppose to be in (Java, C,...?)
if you have any difficulties message me

melina
چهارشنبه 05 بهمن 1384, 23:21 عصر
من متن بالا را به زبان فارسی می نویسم .
کلاسی به نام complex ایجاد کنید و یک برنامه برای آزمایش کلاستان برای اینکه عمل محاسبه مجموعه اعداد را انجام دهد ، بنویسید.
مجموعه اعداد از realpart + imaginarypart *i where i is radical -1
از متغیر double استفاده کنید وداده های خصوصی کلاس را نمایش دهید . یک constructor
( سازنده ) آماده کنید که توانایی داشته باشد یک object از کلاس را مقداردهی ( initializers ) نمایید در زمانیکه آنها اعلان می شوند.
constructor باید default values را در مرحله ای که اعلان نشده آماده کند.
عضوهای عمومی تابع را برای هر یک از موارد زیر آماده کنید :
1) دو عضو complex (مجموعه ) ا ضافه کنید .real part به یکدیگر اضافه می شود و
imaginary part به یکدیگر .
2)دو عضو مجموعه را کم کنید :
real part راست دستورالعمل ( right operand) از real part چپ دستورالعمل ( left operand ) می کاهد و imaginary part راست دستورالعمل ازimaginary part چپ دستورالعمل کاهش میدهد
3) مجموعه اعضا از (a,b) که real part ,a و imaginary part ,b باشد.



ممنون می شم پاسخ سوال من را بدهید .

melina
جمعه 07 بهمن 1384, 08:29 صبح
زبان برنامه نویسی ++c