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

برنامج مايشتغل ممكن مساعده ضرورى

بدأه دنية القوى في 13 مايو 2011 · 13 رد · 587 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

مساء الخير

كتبت برنامج وعطنى خطأ يقول class main ماهوى موجود وأنا كتبه class main مورضى يشتغل

ممكن تراد على ضرورى

وشكرا.

public class lock{

privet int num1 ;

privet int num2 ;

privet int num3 ;

privet int flag ;

public lock ( ) {

Num1 =1;

Num2 =1;

Num3 =1;

Flag =0;

}

public lock ( int a , int b , int c) {

Num1 =a ;

Num2 =b ;

Num3 = c ;

Flag =0;

}

Public void open ( int a , int b , int c) {

if ( num1 == a && num2 == b && num3==c )

{

Flag = 1;

System.out.println( " the lock is open ") ;

}

else

System.out.println( " the combination was incorrect ") ;

}

Public void close ( ) {

Flag =0;

System.out.println( " the lock is closed ") ;

}

Public void OpenClose ( ) {

If ( flag ==1 )

System.out.println( " the lock is open ") ;

Else

System.out.println( " the lock is close ") ;

Public void ChangCompo ( int a , int b , int c , int d , int e , int f) {

if ( num1 == a && num2 == b && num3==c ){

num1 = d ;

num2 = e ;

num3 = f ;

}

}

}// end class

-----------------------------

Import java.util.Scanner

public class LockTest{

public static void main ( string [] args ){

Lock y = new lock( 5 , 10 , 15 ) ;

B. OpenClosed () ;

B. ChangCompo ( 5 , 10 , 15, 1 , 2 , 3 ) ;

B. Open ( 1, 2, 3);

B. ChangCompo (1 , 2 , 3, 5 , 10 , 15 ) ;

B. Open ( 5 , 10 , 15 ) ;

B.Close ();

System.out.println("the compantion is being changed 30 40 50");

B. ChangCompo ( 5 , 10 , 15, 30 , 40 , 50 ) ;

B. Open ( 5 , 10 , 15 ) ;

B. Open ( 30 , 40 , 50 ) ;

B.Close ();

Scanner input = new Scanner ( system.in ) ;

Int a = input.nextInt();

Int b = input.nextInt();

Int c = input.nextInt();

B. Open ( a , b , c ) ;

}// end main

}// end class

#2

الاخطاء لديكى اخطاء املائيه

فFlag تختلف تماما عن flag

وكذلك الـ num1 , Num1

عدلى هذه وان شاء الله بيشتغل معاكى

Software Developer
Mahmoudkelany.com


 

#3
Mahmoud Kelany كتب:

الاخطاء لديكى اخطاء املائيه

فFlag تختلف تماما عن flag

وكذلك الـ num1 , Num1

عدلى هذه وان شاء الله بيشتغل معاكى

جربت ولكن نفس الشى يوجد خطأ class main غير موجوده

#4

اولا يا اختي انتي عملتي اثنين class عمومين public في ملف واحد

ثانين انتي عامله import في نص البرنامج وهذا لا يجوز ايضا

عندك اخطاء املائية كثيره مثلا private كلها small وليست Private

يمكن بيطلب منك كلاس ماين لانك اول ما عملتيه بالnetbeans عملك كلاس ماين اتوماتيكي بعدين انتي غيرتي اسمه من دون ما تعملي

refactor -> rename

ايضا تذكري ان اسم الملف الــ .java يجب ان يكون مطابق لاسم الــ public class

تم تعديل هذه المشاركة بواسطة mental-driller في 13 مايو 2011 في 22:44

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#5
mental-driller كتب:

اولا يا اختي انتي عملتي اثنين class عمومين public في ملف واحد

ثانين انتي عامله import في نص البرنامج وهذا لا يجوز ايضا

عندك اخطاء املائية كثيره مثلا private كلها small وليست Private

يمكن بيطلب منك كلاس ماين لانك اول ما عملتيه بالnetbeans عملك كلاس ماين اتوماتيكي بعدين انتي غيرتي اسمه من دون ما تعملي

refactor -> rename

ايضا تذكري ان اسم الملف الــ .java يجب ان يكون مطابق لاسم الــ public class

ممكن توضح كيفيت الاستخدام

يمكن بيطلب منك كلاس ماين لانك اول ما عملتيه بالnetbeans عملك كلاس ماين اتوماتيكي بعدين انتي غيرتي اسمه من دون ما تعملي

refactor -> rename

#6

هذه الصورة مرفقه

زي مايقولوا : A picture worths thousand words

تضغطي على اسم الملف وبعدين تحتاري refactor بعدين rename

انا ايضا انصحك تخلي الكلاسين في ملفين منفصلين.

post-244925-082783200 1305316806_thumb.j

المرفقات
Untitled-1.jpg

تم تعديل هذه المشاركة بواسطة mental-driller في 13 مايو 2011 في 23:02

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#7

كيفيه أستخدامه فى برنامج eclipse

#8

هذى أخر تعديل بس مورضى يمشىء الحال

public class lock{

Privet int num1 ;

Privet int num2 ;

Privet int num3 ;

Privet int flag ;

public lock ( ) {

num1 =1;

num2 =1;

num3 =1;

flag =0;

}

public lock ( int a , int b , int c) {

num1 =a ;

num2 =b ;

num3 = c ;

flag =0;

}

Public void open ( int a , int b , int c) {

if ( num1 == a && num2 == b && num3==c )

{

flag = 1;

System.out.println( " the lock is open ") ;

}

else

System.out.println( " the combination was incorrect ") ;

}

Public void close ( ) {

flag =0;

System.out.println( " the lock is closed ") ;

}

Public void OpenClose ( ) {

If ( flag ==1 )

System.out.println( " the lock is open ") ;

else

System.out.println( " the lock is close ") ;

Public void ChangCompo ( int a , int b , int c , int d , int e , int f) {

if ( num1 == a && num2 == b && num3==c ){

num1 = d ;

num2 = e ;

num3 = f ;

}

}

}// end class

-----------------------------

Import java.util.Scanner

public class LockTest{

public static void main ( string [] args ){

Lock y = new lock( 5 , 10 , 15 ) ;

B. OpenClosed () ;

B. ChangCompo ( 5 , 10 , 15, 1 , 2 , 3 ) ;

B. Open ( 1, 2, 3);

B. ChangCompo (1 , 2 , 3, 5 , 10 , 15 ) ;

B. Open ( 5 , 10 , 15 ) ;

B.Close ();

System.out.println("the compantion is being changed 30 40 50");

B. ChangCompo ( 5 , 10 , 15, 30 , 40 , 50 ) ;

B. Open ( 5 , 10 , 15 ) ;

B. Open ( 30 , 40 , 50 ) ;

B.Close ();

Scanner input = new Scanner ( system.in ) ;

Int a = input.nextInt();

Int b = input.nextInt();

Int c = input.nextInt();

B. Open ( a , b , c ) ;

}// end main

}// end class

#9

ها يا اختي عدلت لك الكود حقك والان بيشتغل

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author PSYCHO_ MANTIS
 */
public class lock {

    private int num1;
    private int num2;
    private int num3;
    private int flag;

    public lock() {
        num1 = 1;
        num2 = 1;
        num3 = 1;
        flag = 0;
    }

    public lock(int a, int b, int c) {
        num1 = a;
        num2 = b;
        num3 = c;
        flag = 0;
    }

    public void open(int a, int b, int c) {
        if (num1 == a && num2 == b && num3 == c) {
            flag = 1;
            System.out.println(" the lock is open ");
        } else {
            System.out.println(" the combination was incorrect ");
        }
    }

    public void close() {
        flag = 0;
        System.out.println(" the lock is closed ");
    }

    public void OpenClose() {
        if (flag == 1) {
            System.out.println(" the lock is open ");
        } else {
            System.out.println(" the lock is close ");
        }
    }

    public void ChangCompo(int a, int b, int c, int d, int e, int f) {
        if (num1 == a && num2 == b && num3 == c) {
            num1 = d;
            num2 = e;
            num3 = f;
        }
    }
}// end class

import java.util.Scanner;

public class LockTest{
public static void main ( String [] args ){

lock B = new lock( 5 , 10 , 15 ) ;
B.OpenClose() ;
B.ChangCompo ( 5 , 10 , 15, 1 , 2 , 3 ) ;
B.open ( 1, 2, 3);
B.ChangCompo (1 , 2 , 3, 5 , 10 , 15 ) ;
B.open ( 5 , 10 , 15 ) ;
B.close ();
System.out.println("the compantion is being changed 30 40 50");
B.ChangCompo ( 5 , 10 , 15, 30 , 40 , 50 ) ;
B.open ( 5 , 10 , 15 ) ;
B.open ( 30 , 40 , 50 ) ;
B.close ();

Scanner input = new Scanner ( System.in ) ;
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
B.open ( a , b , c ) ;


}// end main
}// end class

طبعا هذا لا يعني باي شكل ان خورازميتك صحيحه، قد تكون صحيحه او لا ، لاني لم انظر الى الخوارزميه

انتبهي للفورقات بين الحروف capital & small

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#10

شكرا وجزك الله ألف خير

الله يفرج عليك كربتك مثل مافرجت على

بس معلش طلب أخير ممكن أذا ماعليك أمر بس شيكلى على الخورزميه

وشكرا.

#11

اولا : بالنسبة لايكلبس اذا عادك ماعرفتيش تعملي refactor

ثانيا : قبل ما اشوف الخوارزميه اولا يجب ان تقولي لي مالمطلوب من البرنامج وايش مفروض يعمل ،

الشيئ الوحيد اللي ممكن اوصل له من اسم Lock هو موضوع في الــ synchronization لــ threads

post-244925-088888500 1305322867_thumb.j

المرفقات
Untitled-1.jpg

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#12

• Write a Java program to test a combinational lock. The program

should have a Lock class and a TestLock class.

• The key is three numbers each is between 0 and 9

• The class Lock should have the following fields (all are private,

all are type int),:

• first number in the combination

• second number in the combination

• third number in the combination

• flag that tells whether the lock is open or closed

• Your class should have the following methods:

1. default constructor: set the combination to 1 1 1 and set the flag

to closed

2. constructor that accepts initial values for the combination: set

the combination to the values given in the parms and set the flag

to closed

3. open (has parms for the combination used to open the lock): if

the parms given for the combination match the combination, set

the flag to open and print a message stating that the lock is

open, otherwise print a message stating that the combination

was incorrect

4. close (no parms): change the flag to closed, print a message

stating that the lock is closed

5. openClosed (no parms): print a message stating whether the

lock is open or closed

6. changeCombo (parms for the old combination and parms for the

new combination): if the parms given for the old combination are

correct, change the combination to the values given in the parms

for the new combination, print a message stating whether or not

the combination was changed

• Write a Java class called LockTest . This class will contain a main

function to test the ComboLock class. Your main function should

do the following:

1. Create a ComboLock with combination 5 10 15.

2. Check whether the lock is open.

3. Print a message stating that the combination used is 1 2 3, and

then open the lock using combination 1 2 3.

4. Print a message stating that the combination used is 5 10 15,

and then open the lock using combination 5 10 15.

5. Close the lock.

6. Print a message stating that the combination is being changed to

30 40 50, and then change the combination to 30 40 50.

7. Print a message stating that the combination used is 5 10 15,

and then open the lock using combination 5 10 15.

8. Print a message stating that the combination used is 30 40 50,

and then open the lock using combination 30 40 50.

9. Close the lock

10. prompt the user to enter a combination and then try to

open the lock with the combination. (Reading the combination is

reding three integer values between 0 and 9, for example 3 5 6.

For extra credit let the user enter the combination as a three

digit number, for example 356 instead of 3 5 6).

#13

لقد قمت بتشغيل البرنامج عندي وعلى ما يتضح لي انه يعمل بشكل سليم

No intellectual battle was ever won through retreat
You do not watch Gintama? Dude, you are missing a lot!


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#14

شكرا لك

وجزاك الله ألف خير

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