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

كيفبه الاستداع فى main

بدأه دنية القوى في 15 مايو 2011 · 42 رد · 1,568 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#26

تمام ضيفي هذه الداله في نهاية الكلاس حق Account

public int compareBalance(Account i){
        if(balance > i.getBalance())
            return 1;
        else if(balance < i.getBalance())
            return -1;
        else
            return 0;
    }

وضيفي هذا الكود لداله main

if (s1.compareBalance(s2) == 1) {
            System.out.println("S1 balance is bigger than S2 balance");
        } else if (s1.compareBalance(s2) == -1) {
            System.out.println("S2 balance is bigger than S1 balance");
        } else {
            System.out.println("S1 balance is equal to S2 balance");
        }
        System.out.println("The difference between S1 balance and S2 balance is " + (s1.getBalance() - s2.getBalance()));

راح يكون الخرج حقك زي اللي عندي بالصورة

post-244925-009012500 1305568748_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

#27

بس الطلب كان خرج main ودخل class main

#28

قصدك كذه؟

package account;

public class AccountTest {

    public static int compareBalance(Account i, Account j){
        if( i.getBalance() > j.getBalance())
            return 1;
        else if(i.getBalance()<j.getBalance() )
            return -1;
        else
            return 0;
    }

    public static void main(String argv[]) {

        SavingAccount s1 = new SavingAccount(0, 0, 0);

        SavingAccount s2 = new SavingAccount(76523122, 76523122, 25000);
        s2.withdraw(6000);
        s1.deposit(1000);
        s1.setInterest(.04);
        s2.setInterest(.04);
        s2.addInterest();
        s2.showBalance();
        s2.withdraw(2000);
        s2.deposit(2800);
        s2.showBalance();

        if (compareBalance(s2, s2) == 1) {
            System.out.println("S1 balance is bigger than S2 balance");
        } else if (compareBalance(s2, s2) == -1) {
            System.out.println("S2 balance is bigger than S1 balance");
        } else {
            System.out.println("S1 balance is equal to S2 balance");
        }
        System.out.println("The difference between S1 balance and S2 balance is " + (s1.getBalance() - s2.getBalance()));
    }// end main
}// end class

post-244925-025847200 1305569781_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

#29

تكون تحت class main

#30
if (s1.compareBalance(s2) == 1) {            System.out.println("S1 balance is bigger than S2 balance");        } else if (s1.compareBalance(s2) == -1) {            System.out.println("S2 balance is bigger than S1 balance");        } else {            System.out.println("S1 balance is equal to S2 balance");        }        System.out.println("The difference between S1 balance and S2 balance is " + (s1.getBalance() - s2.getBalance()));

أشراح الشرط الانى ما فهمته وش تعنى برقم 1و-1

#31

الماين مش كلاس وانما داله

الشرط يعني انه لو الاول اكبر من الثاني يرجع 1 ولو الثاني اكبر من الاول يرجع -1 ولو متساويين يرجع 0

فانت تفحصي ايش رجعت لك الداله لو رجعت 1 يعني المتغير الاول اكبر من الثاني وكذا

1

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#32

بس هو الزام نضع class راح يطبع invalid أو not invalid

#33

بالتاكيد كل شيئ داخل كلاس

واحنا عندنا ثلاث كلاسات في برنامجك Accout, SavingAccount, AccountTest

الجافا مش مثل السي بلس بلس ، لانه في السي بلس بلس تقدر تعمل الداله ماين لوحدها خارج كلاس

ممكن انه غلطتي في فهم السؤال : ارفقي السؤال لو امكن

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#34

نفس السؤال الآول بس طلب تعديلات

بحيث نسوى ميثد تقوم عمليه المقارنه المبلغ الكل من الحسابين بحيث تطبع أذا كان مافى مبلغ الايوجد أو أذاكان فى مبلغ ويكون موجود مبلغ

بعدين تغاران الحسبين وتراج الحساب الاعلى موقع class(بحيث لاتكون فى main ) وتكون فى class AccomutTest

#35

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

لو مش متاكده من السؤال اطبعيه انجليزي زي ما هو

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#36

طيب يليت تكتب فى حق الكود عشان توضح أكثر

#37

هذا الكلاس AccountTest

public class AccountTest {

    public static int compareBalance(Account i, Account j){
        if( i.getBalance() > j.getBalance())
            return 1;
        else if(i.getBalance()<j.getBalance() )
            return -1;
        else
            return 0;
    }

    public static void main(String argv[]) {

        SavingAccount s1 = new SavingAccount(0, 0, 0);

        SavingAccount s2 = new SavingAccount(76523122, 76523122, 25000);
        s2.withdraw(6000);
        s1.deposit(1000);
        s1.setInterest(.04);
        s2.setInterest(.04);
        s2.addInterest();
        s2.showBalance();
        s2.withdraw(2000);
        s2.deposit(2800);
        s2.showBalance();

        if (compareBalance(s2, s2) == 1) {
            System.out.println("S1 balance is bigger than S2 balance");
        } else if (compareBalance(s2, s2) == -1) {
            System.out.println("S2 balance is bigger than S1 balance");
        } else {
            System.out.println("S1 balance is equal to S2 balance");
        }
        System.out.println("The difference between S1 balance and S2 balance is " + (s1.getBalance() - s2.getBalance()));
    }// end main
}// end class

اعتقد انه من الاسهل عليكي انكي تجيبي لي السؤال الانجليزي ولا زي ماهو مكتوب عندك وانا بقرأة

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#38

أنت مسوى نصف الشرط فى main المفروض ما نضع فيه شىء يخص عمليه المقارنه بعدين أنا منى فهمه الشرط وضع s2,s2 طيب ون راح s1 فى عمليه المقارنه

#39

يعني انتي تشتيه كذا ؟

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

public class AccountTest {

    public static int compareBalance(Account i, Account j){
        if( i.getBalance() > j.getBalance()){
                        System.out.println("S1 balance is bigger than S2 balance");

            return 1;
        }
        else if(i.getBalance()<j.getBalance() )
        {System.out.println("S2 balance is bigger than S1 balance");
            return -1;
        }
        else{
             System.out.println("S1 balance is equal to S2 balance");
             return 0;
        }

    }

    public static void main(String argv[]) {

        SavingAccount s1 = new SavingAccount(0, 0, 0);

        SavingAccount s2 = new SavingAccount(76523122, 76523122, 25000);
        s2.withdraw(6000);
        s1.deposit(1000);
        s1.setInterest(.04);
        s2.setInterest(.04);
        s2.addInterest();
        s2.showBalance();
        s2.withdraw(2000);
        s2.deposit(2800);
        s2.showBalance();


        System.out.println("The difference between S1 balance and S2 balance is " + (s1.getBalance() - s2.getBalance()));
    }// end main
}// end class

تشتي الطباعة تتم داخل الدالة؟

ممكن بس كحس تصميمي ليس من المنطقي انه تخلي داله حسابية تطبع

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#40

مساء الخير

حولت مع البرنامج بس مورضى يشتغل يخرج لى

run:
java.lang.NoClassDefFoundError: account1/Main
Caused by: java.lang.ClassNotFoundException: account1.Main
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: account1.Main.  Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
#41

يا اختي انتي مسيمه الكلاسس Account1 وانا مسيمه Account ابعدي ال1

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

#42

شكرا جزاك الله ألف خير على مقدمته

#43

خلاص ؟ لو عندك اي استفسارات ثانيه إن شاء الله بنكون في الخدمه

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


صورةmsrgb1485.gif ocajavase7programmerclr.gif

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