الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف - طلب حل : ]مساعدة عاجلة في الجافا

مغلق
بدأه جريحة الامس في 10 ديسمبر 2010 · 8 رد · 476 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

مطلوب مني اني اضع كودات 4 من خوارزميات البحث (Insertion,quick,counting,merage) في كود جافا داااخل interface

انا معي الكودات الاربعة بس مش عارفة اربطهم داخل interface بتمنى المساعدة منكم باسرع وقت بعد ادنكم

الكوداات في الاسفل وتجدوه ايضا مع المرفقات:-

//insertion

void sort(int a[]) throws Exception {

for (int i = 1; i < a.length; i++) {

int j = i;

int B = a;

while ((j > 0) && (a[j-1] > B)) {

if (stopRequested) {

return;

}

a[j] = a[j-1];

j--;

pause(i,j);

}

a[j] = B;

pause(i,j);

}

}

}

//MergeSort

class MergeSortAlgorithm extends SortAlgorithm {

void sort(int a[], int lo0, int hi0) throws Exception {

int lo = lo0;

int hi = hi0;

pause(lo, hi);

if (lo >= hi) {

return;

}

int mid = (lo + hi) / 2;

/*

* Partition the list into two lists and sort them recursively

*/

sort(a, lo, mid);

sort(a, mid + 1, hi);

/*

* Merge the two sorted lists

*/

int end_lo = mid;

int start_hi = mid + 1;

while ((lo <= end_lo) && (start_hi <= hi)) {

pause(lo);

if (stopRequested) {

return;

}

if (a[lo] < a[start_hi]) {

lo++;

} else {

/*

* a[lo] >= a[start_hi]

* The next element comes from the second list,

* move the a[start_hi] element into the next

* position and shuffle all the other elements up.

*/

int T = a[start_hi];

for (int k = start_hi - 1; k >= lo; k--) {

a[k+1] = a[k];

pause(lo);

}

a[lo] = T;

lo++;

end_lo++;

start_hi++;

}

}

}

void sort(int a[]) throws Exception {

sort(a, 0, a.length-1);

}

}

//QuickSort

class QSortAlgorithm extends SortAlgorithm {

void sort(int a[], int lo0, int hi0) throws Exception {

int lo = lo0;

int hi = hi0;

pause(lo, hi);

if (lo >= hi) {

return;

}

else if( lo == hi - 1 ) {

/*

* sort a two element list by swapping if necessary

*/

if (a[lo] > a[hi]) {

int T = a[lo];

a[lo] = a[hi];

a[hi] = T;

}

return;

}

/*

* Pick a pivot and move it out of the way

*/

int pivot = a[(lo + hi) / 2];

a[(lo + hi) / 2] = a[hi];

a[hi] = pivot;

while( lo < hi ) {

/*

* Search forward from a[lo] until an element is found that

* is greater than the pivot or lo >= hi

*/

while (a[lo] <= pivot && lo < hi) {

lo++;

}

/*

* Search backward from a[hi] until element is found that

* is less than the pivot, or lo >= hi

*/

while (pivot <= a[hi] && lo < hi ) {

hi--;

}

/*

* Swap elements a[lo] and a[hi]

*/

if( lo < hi ) {

int T = a[lo];

a[lo] = a[hi];

a[hi] = T;

pause();

}

if (stopRequested) {

return;

}

}

/*

* Put the median in the "center" of the list

*/

a[hi0] = a[hi];

a[hi] = pivot;

/*

* Recursive calls, elements a[lo0] to a[lo-1] are less than or

* equal to pivot, elements a[hi+1] to a[hi0] are greater than

* pivot.

*/

sort(a, lo0, lo-1);

sort(a, hi+1, hi0);

}

void sort(int a[]) throws Exception {

sort(a, 0, a.length-1);

}

}

//counting sort

import java.util.Arrays;

public static void countingSort(int[] a, int low, int high)

{

int[] counts = new int[high - low + 1]; // this will hold all possible values, from low to high

for (int x : a)

counts[x - low]++; // - low so the lowest possible value is always 0

int current = 0;

for (int i = 0; i < counts.length; i++)

{

Arrays.fill(a, current, current + counts, i + low); // fills counts elements of value i + low in current

current += counts; // leap forward by counts steps

}

}

الرجاااء المساااعدة باسرع وقت

sort alg code.txt

#2

لم اراجع الالجوريزمات ولكن فى حاله انها صحيحه ... فقد تعديت الجزء الصعب ما مشكلتك مع الانترفيس اذا كنت

ضعيفه فيه كلاس الswing استخدمى بيئه النت بينز مثلا لعمل الانترفيس desktop application

اصنعى فورم وعليها اربعه ازرار مثلا وعند الضغط على اى منها تظهر panel عليها البيانات التى سوف يدخلها اليوزر

والخاصه بالالجوريزم الذى اختاره .. ما المشكله ؟

no-pain-no-gain.jpg

اذا كنت لا تعلم الى اين تذهب... فكــل الطرق تؤدى الى هناك

#3

يرجى وضع محاولاتك

وايضا هناك لبس من حيث كلمه interface

انا فهمتها فالاول انها public interface

ككود يعنى وكدا

انما حضرتك عاوز GUI Interface تفرق كتيييييييير

يرجى التوضيح

وعرض محاولاتك ونساعدك فيها ان شاء الله

Software Developer
Mahmoudkelany.com


 

#4

اخواااني المقصود بالinterface هوة ال public وليس GUI

مشكلتي انني ضعيفة في الانترفيس الكوداات فاهمها وبعرف اكتبها ككود وليس كinterface

#5
جريحة الامس كتب:

اخواااني المقصود بالinterface هوة ال public وليس GUI

مشكلتي انني ضعيفة في الانترفيس الكوداات فاهمها وبعرف اكتبها ككود وليس كinterface

انا دورت لحضرتك على دروس فالمنتدى لكن مش لقيت

للكن ممكن حضرتك الاستعانه بهذه الروابط

http://www.forums.fci4all.com/index.php?showtopic=16582

http://en.wikipedia.org/wiki/Interface_%28Java%29

http://download.oracle.com/javase/tutorial/java/concepts/interface.html

http://download.oracle.com/javase/tutorial/java/IandI/createinterface.html

وحاولى فى الموضوع ولو فيه اخطاء معكى اعرضى الكود الخاص بالمشروع

وان شاء الله بنساعدك

بالتوفيق

Software Developer
Mahmoudkelany.com


 

#6

اخ محمود بشكر تعاونك

بس بصراحة ما عرفت استفيد من اللنكات حتى اقدر احل الوظيفة :(

عكل حال جزاك الله خيرا

#7

أختي داخل الـInterface مابتكتبي أي كود , انتي بس تنشئي Interface جديد وتكتبي داخله أسامي الدوال اللي بتستخدميها بدون ماتكتبي داخلها أي كود زي كذا :

public interface MyInterface{

public void sort(int a[], int lo0, int hi0) ;

public void secMethod(Object  parm1,Object  parm2);

}

,بس هذا بالنسبه للأنترفيس , وبعدين لما تسويله implements من الكلاس الرئيسي تكتبي نفس أسامي الدوال اللي كتبتيها في الأنترفيس ولكن هذه المره تكتبي فيها الكود وتسمى هذه العمليه override , زي كذا :

public class MyClass implements MyInterface{

public void sort(int a[], int lo0, int hi0) {

//do something

}

public void secMethod(Object  parm1,Object  parm2){

//do something

}


}

وضحت الفكره أختي؟

تم تعديل هذه المشاركة بواسطة M.Allaw في 11 ديسمبر 2010 في 00:49


HeartOutputStream myHeart;
OutputStream myHeartOutStream;

myHeartOutStream = MAllaw.getHeart().getOutputStream();
myHeart = new HeartOutputStream(myHeartOutStream);

while(myHeart.isStillBeating())
myHeart.write("I ♥ Java");

#8

اخي الكريم انا الانترفيس ما اخدتو ابدا في دراستي وهاد الواجب هوة كعلامة مشاركة

يعني انا مش قادرة افهمو ياريت لو تقدر تعملي اياه انا جهزت لكل وحدة كود

#9

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته.

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة طلب حل الواجبات والتمارين.

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…