واجهتني مشكله صغيره في طريقه وضع بيانات من array الي queue بمعني اريد نقل عناصر وبيانات موجوده ومخزنه داخل مصفوفه الي queue ...؟


واجهتني مشكله صغيره في طريقه وضع بيانات من array الي queue بمعني اريد نقل عناصر وبيانات موجوده ومخزنه داخل مصفوفه الي queue ...؟


String[] array = {"elem1", "elem2", "elem3"};
ArrayDeque<String> queue = new ArrayDeque<String>();
for (int i = 0; i < array.length; i++) {
queue.add(array);
}
System.out.println(queue.poll());
System.out.println(queue.poll());
System.out.println(queue.poll());اشكرك كثيرا اخ NullOne لقد نبهتني الى نقطة لم انتبه لها وراجعت الكود ككل والحمد لله الان خاصية عرض البيانات تعمل بشكل جيد..
بس سؤال بسيط اخ NullOne طبعا بعد عرض البيانات في الحقول الخاصة بها وبعد ان اقوم بالتعديل عليها ساضغط على زر "تحديث" لتحديث البيانات في قاعدة البيانات
لكن انا قمت بوضع كود الاضافة داخل ال action الخاص بالتحديث لانني افترض اسوا افتراض وهو ان يقوم المستخدم بتغيير جميع البيانات في الحقول وعندما يضغط على تحديث فكانما اضاف بيانات جديدة لقاعدة البيانات.
تفاجات انه يظهر لي خطا general error لا اعلم سببها
ارجو الا اكون اثقلت عليك
بالنسبة للبرنامج يمكن ان ارسله لك على الخاص
بارك الله فيك وجعل عملك هذا في ميزان حسناتك
السلام عليكم ورحمه الله وبركآته
سؤالى هو اني اريد من البرنامج عمل Call لـstatus_of_card
لكنى لا اعلم مالذى يجب وضعه فى الشرط if
انظرو لـout put3
إذاقام بطبع الجملة الأخيرة يخرج من البرنامج :excl:
Sample output 3: (when some books issued previously, have not been returned) Enter card number: 650 Enter days left for the validation: 30 Enter number of books issued previously: 6 Enter number of books returned previously: 3 No further operations can be made. Some books are still not returned
وهنا السؤال كاملا:
You are simply required to submit a source file ( .java ) that includes the implementation of the above mentioned program.
Write a java program that has following class
Opt_library
Which should have the following Private data members and member functions.
1- card_number
2- valid_days_left
3- books_issued
4- books_returned
5- Number_of_books
Make a member function that will find out the previous status of the card before making the next operation. This member function will check whether it is required to return some books on the particular card or the status has been cleared.
The status will be cleared if all the issued books have also returned.
Display the messages accordingly, saying
“The status has been cleared”
or
“No further operations can be made. Some books are still not returned”
If the user enters books_returned which are more than books_issued, an appropriate message should be displayed saying;
“Number of books returned cannot be greater than number of books issued”
Make a member function named as issue_books that issue books against the current operation on the library card.
More than 2 books cannot be issued in one operation. If a user enters more than 2 books for the Number_of_books, the program displays the message saying;
“More than 2 books cannot be issued at a time”
Books can only be issued if the valid_days_left are greater than or equal to 15 days.
If the valid_days_left is less than 15, the program quits after displaying an appropriate message saying;
“Books cannot be issued, there are not enough days left for the validity of card”
Make another member function named as display that will finally display the message after the issue of the books saying’
Number_of_books book(s), issued to the card_number.
Checks for negative values will be encouraged to implement.
Write getters and setters of all data member. Also write constructor and destructor.
الحـــل :
import java.util.Scanner;
public class Opt_libarary
{
private int Card_Number;
private int Valid_Days;
private int Book_Issued;
private int Books_Returned;
private int Number_Of_Books;
public Opt_libarary()
{
Scanner input=new Scanner(System.in);
System.out.print("Enter card number:");
Card_Number=input.nextInt();
System.out.print("Enter card number:");
Valid_Days=input.nextInt();
System.out.print("Enter card number:");
Book_Issued=input.nextInt();
System.out.print("Enter card number:");
Books_Returned=input.nextInt();
Number_Of_Books=0;
}
public void setCard_Number(int C_N)
{
Card_Number=C_N;
}
public int getCard_Number()
{
return Card_Number;
}
//_______________________________________
public void setValid_Days(int V_D)
{
Valid_Days=V_D;
}
public int getValid_Days()
{
return Valid_Days;
}
//___________________________________________
public void setBook_Issued(int B_I)
{
Book_Issued=B_I;
}
public int getBook_Issued()
{
return Book_Issued;
}
//_____________________________________________
public void setBooks_Returned(int B_R)
{
Books_Returned=B_R;
}
public int getBooks_Returned()
{
return Books_Returned;
}
//______________________________________________
public void setNumber_Of_Books(int N_O_B)
{
Number_Of_Books=N_O_B;
}
public int getNumber_Of_Books()
{
return Number_Of_Books;
}
//___________________________________________________________________________________________________________
public void display()
{
System.out.println("Number_of_books:"+Number_Of_Books + "issued to the card_number:"+Card_Number);
}
public int status_of_card()
{
if(Books_Returned==Book_Issued)
{
System.out.println("The status has been cleard");
return 1;
}
else if(Books_Returned<Book_Issued)
{
System.out.println("No further opration can be made.Some books are still not returned");
return 1;
}
else
{
System.out.println("Number of book returned cannot be grater than number of book issud");
return 0;
}
}
public int issud_book()
{
if(Number_Of_Books>2)
System.out.println("More than 2 books cannot be issud at a time");
else
{
if(Valid_Days<15)
{
System.out.println("Books cannot be issud,there are not enough deys left for the validity of card");
return 0;
}
else
return 1;
}
return 0;
}
}
public class opt_libararyTest
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
Opt_libarary Opt_li=new opt_libarary();
System.out.println("Card number: " + Opt_li.getCard_Number());
System.out.println("Card number: " + Opt_li.getCard_Number());
System.out.println("Card number: " + Opt_li.getCard_Number());
System.out.println("Card number: " + Opt_li.getCard_Number());
//__________________erorr
public int check_status()
{
if( Opt_li.status_of_card())
//{
// Opt_li.issud_book();
// return 0;
// }
// else
// return 1;
}
}
}ارجوووومنكم المساعده الله يسعدكم لان لدى اختبار الاسبوع القآدم واريد الحصول على الـfull mark :)..
ولكم جزيل الشكر :wub:
استغفر الله واتوب اليه ..~
لآاله الاانت سبحانك انى كنت من الظالمين ..~
Tigger_it كتب:ما مر علي كلاس ArrayDeque ممكن توضع اكثر عنو
لم أفهم كلامك :blink:
على العموم، الفئة java.util.ArrayDeque تعمل implement للinterface Queue مما يتيح استعمالها كqueue
add تقوم بإضافة عنصر ما إلى مؤخرة الqueue
poll تزيل العنصر الاول من الqueue وتعيد قيمته
السلام عيكم ..
لدى سؤال اخر :blush: اثناءالمذاكره وجدت هذا السؤال :
1-Method Minimum, which takes 3 integers and returns the minimum of three integers
2-Method Minimum, which takes 2 integers and returns the minimum of three integers
public int minimum(int x,int y,int z)
{
int minimumValue=x;
if( y<minimumValue)
minimumValue=y;
if( z<minimumValue)
minimumValue=z;
return minimumValue;الوظيفه الاولى قدرت احلها كما سبق ولا اريد توضيح فيها :) لكن سؤالى هو كيف اقدر اغير فى هذة الوظيفه لتاخذ رقمين فقط كما هو مطلوب فالفقره الثانيه من السؤال ؟
وشكرا لكم
استغفر الله واتوب اليه ..~
لآاله الاانت سبحانك انى كنت من الظالمين ..~
قمت بعمل class خاص بتعديل البيانات وهو على الشكل التالي
package Database;
import Entity.Student;
import java.sql.*;
public class UpdateStudentDB {
MemorizeDB aMemorizeDB = MemorizeDB.getAMemorizeDB();
Statement aStatement = aMemorizeDB.getStatement();
public UpdateStudentDB () {
}
public void Update(Student aStudent) {
String updSQL ="update Student" +
"set"+
"StdID =(" +
aStudent.getStd_ID() + ")" +
"StdName =("+
aStudent.getStd_name() + ")," +
"StdAddress =("+
aStudent.getStd_Address() + ")," +
"StdBirthday =("+
aStudent.getStd_Birthday() + ")," +
"StdPhoneNo =("+
aStudent.getStd_Phone_No() + ")," +
"StdMobileNo =("+
aStudent.getStd_Mobile_No() + ")," +
"GuardianName =("+
aStudent.getStd_GuardianName() + ")," +
"RegDate =("+
aStudent.getStd_reg_Date() + ")," +
"WorkOfGuardian =("+
aStudent.getWork_Of_Guardian()+ ")," +
"StdShip =("+
aStudent.getStd_ship() + ")," +
"StdEdu =("+
aStudent.getStd_Edu() + ")," +
" where StdID = ("+
aStudent.getStd_ID()+")";
try {
aStatement.executeUpdate(updSQL);
}
catch (Exception e)
{
}
}
}بعد ذلك عمت بوضع action لزر "التحديث" وال action كالتالي
Student aStudent = new Student();
aStudent.setStd_reg_Date(reg_Field.getText());
aStudent.setStd_name(std_Name.getText());
aStudent.setStd_ID(Integer.parseInt(std_No.getText()));
aStudent.setStd_Address(std_Address.getText());
aStudent.setStd_Birthday(std_Birthday.getText());
aStudent.setStd_Phone_No(Integer.parseInt(phone_No.getText()));
aStudent.setStd_Mobile_No(Integer.parseInt(Mobile_No.getText()));
aStudent.setStd_GuardianName(guardian_Name.getText());
aStudent.setWork_Of_Guardian(guardian_Work.getText());
aStudent.setStd_ship(std_ship.getText());
aStudent.setStd_Edu(std_Edu.getText());
UpdateStudentDB aUpdateStudentDB = new UpdateStudentDB();
aUpdateStudentDB.Update(aStudent);
JOptionPane.showMessageDialog(rootPane,"Modify have been successfully");بعد الضغط على زر "تحديث" يظهر لي الرسالة والتي تدل على ان التعديل تم بنجاح Modify have been successfully
لكن في الحقيقة لم يعدل شيء في قاعدة البيانات
فما هو حل المشكلة بارك الله فيكم
اخي الكريم
المشكلة اللي بتظهر انه في خطا في update
لماذا تستخدمي الأقواس الدائرية بعد عملية المساواة
أعتقد أن ال single cote هي المستخدمة
هذا على الأغلب خطأ في جملة التعديل ابحثي عن جملة update في google
تحياتي
Integer.MAX_VALUE
هل هما اسم الاوبجك والاخر الميثود ؟؟
وجزاك الله خير
استغفر الله واتوب اليه ..~
لآاله الاانت سبحانك انى كنت من الظالمين ..~
اخي الكريم الرسالة بالتحديد كالتالي
syntax error in UPDATE statement
قمت بعمل الخطوات التي تكلمت عنها لكن دون فائدة
قومي بطباعة جملة update التي قمتي بإنشاءها واعرضيها هنا
لا يوجد ما يمكن أن أفيدك به لأن المشكلة ليست في جافا المشكلة في DB
اطلعي على هذه الوضلة
http://www.w3schools.com/SQl/sql_update.asp
الأخت sa7bah*
هذا المتغير يحتوي على أكبر قيمة ممكن أن يأخذها عدد صحيح int
بالمناسبة الفقرة نفسها غير واضحة
كيف ستأخذ رقمين وسترجع الأقل ما بين ثلاثة أرقام
يهيألي أن هناك لبس ما
تحياتي
السلام عليكم ورحمه الله وبركاته .. ,
طلب مني إنشاء Class أسمه A يحوي المتغيرات الخاصة (name,age).. و إنشاء constructor لضبط قيم المتغيرات الخاصة بما سيرسل له ..
و بعد ذلك إنشاء Class B موروث من A ويحوي المتغير (mark) , و له constructor يستقبل القيم التالية : name و mark ويضبطها ..
كتبت كذا و يقول خطأ !!
الـ Class A
public class A {
private String name ;
private int age ;
public A (String name , int age)
{
this.name=name;
this.age=age;
}
}والـ Class B
public class B extends A
{
private float mark;
public B(String name , float mark)
{
super(name);
this.mark=mark;
}
}مالخطأ ؟
سبحآن الله وبحمده .. سبحآن الله العظيم .. ,
عدلت في الـ Class A و ماطلع فيه خطأ , بس ما أدري اللي سويته صح ولا خطأ ؟؟
public class A {
private String name ;
private int age ;
public A (String name , int age)
{
this.name=name;
this.age=age;
}
public A (String name )
{
this.name=name;
}
}سبحآن الله وبحمده .. سبحآن الله العظيم .. ,
interface Inter1{اريد أن اعرف كيف اعبي المثيود والطريقة الصحيحة وهل بناء هذا البرنامج صح ؟
افزع يا herch
تم تعديل هذه المشاركة بواسطة herch في 25 ديسمبر 2009 في 20:31 — السبب: الوسم [code] + لا توجه سؤالك لشخص بالتحديد
@ إشراقــه فجــر
super تمثل الفئة الأم، اي الفئة التي ورثنا منها، وبالتالي عندما قمت بالتالي في الفئة B
super(name);
فقد قمت بالمناداة على الconstructor الخاص بالكلاس الأم A، والذي ينتظر argument من صنف String. وبما أنك في الأول لم تكتبي constructor من هذا النوع فقد كنت تحصلين على خطأ.
في الكود الثاني أضفت constructor للفئة A ينتظر argument من صنف String، لذلك اختفى الخطأ، لكن يستحسن أن تعطي للمتغير age قيمة ما.
@ Haha_saa
من الأفضل ألا توجه سؤالك لشخص بالتحديد، لان هذا سيحرمك من أجوبة الآخرين.
كيف تملأ الميثود؟؟ هذا يعتمد على الذي تريده من هذه الطريقة أن تفعل. مثلا
public void f1 () {
System.out.println("This is f1 method");
}
public void f2 () {
System.out.println("This is f2 method");
}
public void f3() {
System.out.println("This is f3 method");
}herch كتب:@ إشراقــه فجــر
super تمثل الفئة الأم، اي الفئة التي ورثنا منها، وبالتالي عندما قمت بالتالي في الفئة B
super(name);فقد قمت بالمناداة على الconstructor الخاص بالكلاس الأم A، والذي ينتظر argument من صنف String. وبما أنك في الأول لم تكتبي constructor من هذا النوع فقد كنت تحصلين على خطأ.
في الكود الثاني أضفت constructor للفئة A ينتظر argument من صنف String، لذلك اختفى الخطأ، لكن يستحسن أن تعطي للمتغير age قيمة ما.
الله يجزاك خير , لكن ممكن توضح لي " يستحسن أن تعطي للمتغير age قيمة ما. "
ما فهمت :sad: ..
ليش أعطي الـ age قيمة ؟ طالب في السؤال أنه يضبط قيم المتغيرات الـ name , mark ؟
سبحآن الله وبحمده .. سبحآن الله العظيم .. ,
اقتباسطلب مني إنشاء Class أسمه A يحوي المتغيرات الخاصة (name,age).. و إنشاء constructor لضبط قيم المتغيرات الخاصة بما سيرسل له ..
أتكلم عن الconstructor الذي كتبت في الفئة A. تقومين داخله بتحديد قيمة name، لكنك لم تحددي قيمة age، وستكون بالتالي قيمته هي صفر
أخوي عصام , إذا سمحت وضح لي أكثر ,
والله ما فهمت ..
أستحملني شوي :sad: ..
سبحآن الله وبحمده .. سبحآن الله العظيم .. ,
عندما كتبت داخل B السطر التالي
super(name);
فإنك ناديت على هذا الconstructor
public A (String name ) { ...داخل هذا الconstructor قمت بتحديد قيمة name فقط، لكن ما هي قيمة age؟؟
herch كتب:عندما كتبت داخل B السطر التالي
super(name);فإنك ناديت على هذا الconstructor
public A (String name ) { ...داخل هذا الconstructor قمت بتحديد قيمة name فقط، لكن ما هي قيمة age؟؟
صحيح ما أعطيت قيمة للمتغير age , لأنه في السؤال مطلوب أنشىء Class B يحوي المتغير mark و له constructor ( يقوم بضبط القيم name, mark ) ولاطلب ضبط قيمة age ..
علشان أفهم و ترتاح مني ..
كيف بتكتب الـ Class B و الـ constructor وفق المطلوب بالسؤال ..
والله يوفقك ..
سبحآن الله وبحمده .. سبحآن الله العظيم .. ,
منطقيا يجب إعطاء قيمة لage، وأظن أن السؤال طرح بشكل غير موفق
على العموم يمكن الإستغناء عن الconstructor الثاني الذي كتبت في A، والإكتفاء بتمرير name وقيمة ما تمثل العمر إلى super
public class A {
private String name;
private int age;
public A(String name, int age) {
this.name = name;
this.age = age;
}
}public class B extends A {
private float mark;
public B(String name, float mark) {
super(name, 20);
this.mark = mark;
}
}تم تعديل هذه المشاركة بواسطة herch في 25 ديسمبر 2009 في 21:57
هذا الموضوع مغلق.
المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية
جارٍ التحقق من المتواجدين…