اذهب إلى المحتوى

RAA

الأعضاء
  • المساهمات

    43
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو RAA

  1. طيب بالنسبة لمعلومات العميل المدخلة كيف ممكن تنطبع معاهم؟
  2. شكرًا لك حليت المشكلة
  3. في حالة ابا اعمل في كلاس الفاتورة ميثود تستقبل المنتجات التي اختارها العميل ومعلوماته والمجموع الكلي للسعر كيف ممكن تتعمل؟ public class Invoices { public double total; private Customer customer; private Product product; public Invoices (double total0,Product product0,Customer customer0){ this.total=total0; this.product = new Product(product0); this.customer= new Customer(customer0); } public Invoices(){ this.total=0; this.product=null; this.customer=null; } public double getTotal() { return total; } public void setTotal(double total) { this.total = total; } public Product getProduct() { return new Product (product); } public void setProduct(Product product) { this.product = new Product (product); } public Customer getCustomer() { return new Customer (customer); } public void setCustomer(Customer customer) { this.customer = new Customer (customer); } public String toString(){ String text=""" Invoices information : Customer information : """+this.customer+ "\nThe products :\n"+this.product+"\nThe total price :" +this.total; return text; } }
  4. Exception in thread "main" java.lang.ExceptionInInitializerError
  5. كيف ممكن اعملهم 1-ميثود في كلاس الفاتورة لانشاء الطلب تستقبل المنتجات المختارة من الميثود Select الموجودة في كلاس المنتجات 2-ميثود في كلاس الفاتورة تستقبل الطلب + تستقبل معللومات العميل من كلاس العميل + المجموع الكلي للطلب public class Invoices { public double total; private Customer customer; private Product product; public Invoices (double total0,Product products0,Customer customer0){ this.total=total0; this.product = new Product(products0); this.customer= new Customer(customer0); } public Invoices(){ this.total=0; this.product=null; this.customer=null; } public double getTotal() { return total; } public void setTotal(double total) { this.total = total; } public Product getProduct() { return new Product (product); } public void setProduct(Product products) { this.product = new Product (products); } public Customer getCustomer() { return new Customer (customer); } public class Invoices { public double total; private Customer customer; private Product product; public Invoices (double total0,Product products0,Customer customer0){ this.total=total0; this.product = new Product(products0); this.customer= new Customer(customer0); } public Invoices(){ this.total=0; this.product=null; this.customer=null; } public double getTotal() { return total; } public void setTotal(double total) { this.total = total; } public Product getProduct() { return new Product (product); } public void setProduct(Product products) { this.product = new Product (products); } public Customer getCustomer() { return new Customer (customer); } public void setCustomer(Customer customer) { this.customer = new Customer (customer); } public String toString(){ String text=""" Invoices information : Customer information : """+this.customer+ "\nThe products :\n"+this.product+"\nThe total price :" +this.total; Return text; return null; } }
  6. طباعة البيانات التي تعيدها دالة البحث SelectProducts في الدالة الرئيسية import java.util.ArrayList; import java.util.Scanner; public class SuperMarket { public static void main(String[] args) { ArrayList<Product> list = new ArrayList<>(); Product p1 = new Product("Apple", "fruits", 347685, 39); Product p2 = new Product("carrot", "vegetables", 354305, 39); Product p3 = new Product("tea", "herbs", 389545, 39); System.out.println(); list.add(p1); list.add(p2); list.add(p3); Scanner input = new Scanner(System.in); System.out.println("enter the ID number of the product you want, 0 to exit"); int ProductID = input.nextInt(); while (ProductID != 0) { Product p = Product.SelectProducts(list, ProductID); p.toString(); System.out.println("enter the ID number of the product you want, 0 to exit"); ProductID = input.nextInt(); } } } import java.util.ArrayList; import java.util.Scanner; public class Product { private String productsName; private String productsType; private int productsID; private double productsPrice; private Object list; public Product() { productsName = null; productsType = null; productsID = 0; productsPrice = 0.0; } public Product(String productsName, String productsType, int productsID, double productsPrice) { this.productsName = productsName; this.productsType = productsType; this.productsID = productsID; this.productsPrice = productsPrice; } public void setproductsName(String productsName) { this.productsName = productsName; } public void setproductsType(String productsType) { this.productsType = productsType; } public void setproductsID(int productsID) { this.productsID = productsID; } public void setproductsPrice(int productsPrice) { this.productsPrice = productsPrice; } public String getproductsName() { return this.productsName; } public String getproductsType() { return this.productsType; } public int getproductsID() { return this.productsID; } public double getproductsPrice() { return this.productsPrice; } public String toString() { String str = "Products name :\n " + productsName + "\nProducts type: \n" + productsType + "\nProducts ID: " + productsID + " Products price:\n " + productsPrice; return str; } public static void Search(ArrayList<Product> list, String productsName) { for (int i = 0; i < list.size(); i++) { String currentProductName = list.get(i).getproductsName(); if (productsName.equals(currentProductName)) { System.out.println("This product is available"); return; } } System.out.println("Sorry,this product is not available"); } public static Product SelectProducts(ArrayList<Product> list, int productsID) { for (int i = 0; i < list.size(); i++) { Product currentProduct = list.get(i); int currentProductID = currentProduct.getproductsID(); if (productsID == currentProductID) { System.out.println("informations related to this product ID:%d =" + currentProductID); return currentProduct; } } System.out.println("Sorry but this product ID is wrong"); return null; } }
  7. public static Product SelectProducts(ArrayList<Product> list,int productsID) { for(int i =0; i<list.size();i++) { int currentProductID= list.get(i).getproductsID(); if(productsID==currentProductID) { System.out.println("informations related to this product ID:%d =" + currentProductID); return list.get(i); } } System.out.println("Sorry but this product ID is wrong"); return null ; } برضو المشكلة ذاتها بيانات Id اللي بدخلو ما بتظهر
  8. انا ما احتاج انو يبحث موجود ولا لا انا احتاج انو يبحث اذا موجود يظهر لي معلومات هذا المنتج ومن ثم يرسلوا للكلاس الخاصة بال order وفي حالة انو ادخل ID مش موجود بيظهر رسالة انو خطأ ويعيد ادخال ID وعذرا على الازعاج
  9. package pkgsuper.market; import java.util.ArrayList; import java.util.Scanner; public class SuperMarket { public static void main(String[] args) { ArrayList<Product> list = new ArrayList<>(); Product p1 = new Product("Apple","fruits",347685,39); Product p2 = new Product("carrot","vegetables",354305,39); Product p3 = new Product("tea","herbs",389545,39); System.out.println(); list.add(p1); list.add(p2); list.add(p3); Scanner input = new Scanner();بيخرج ايرور\\ا System.out.println("enter the ID number of the product you want, 0 to exit"); int ProductID = input.nextInt(); while(ProductID != 0) { Product.SelectProducts(list,ProductID); System.out.println("enter the ID number of the product you want, 0 to exit"); ProductID = input.nextInt(); } } } package pkgsuper.market; import java.util.ArrayList; import java.util.Scanner; public class Product { private String productsName; private String productsType; private int productsID; private double productsPrice; private Object list; public Product() { productsName= null; productsType= null; productsID = 0; productsPrice = 0.0; } public Product(String productsName,String productsType,int productsID,double productsPrice ) { this.productsName = productsName; this.productsType = productsType; this.productsID = productsID; this.productsPrice = productsPrice; } public void setproductsName(String productsName) { this.productsName = productsName; } public void setproductsType(String productsType) { this.productsType = productsType; } public void setproductsID(int productsID) { this.productsID = productsID; } public void setproductsPrice(int productsPrice) { this.productsPrice = productsPrice; } public String getproductsName() { return this.productsName; } public String getproductsType() { return this.productsType; } public int getproductsID() { return this.productsID; } public double getproductsPrice() { return this.productsPrice; } public String toString() { String str = "Products name :\n " + productsName + "\nProducts type: \n" + productsType + "\nProducts ID: " + productsID + " Products price:\n " + productsPrice; return str; } public static void Search(ArrayList<Product> list,String productsName) { for(int i =0; i<list.size();i++) { String currentProductName = list.get(i).getproductsName(); if(productsName.equals(currentProductName)) { System.out.println("This product is available"); return; } } System.out.println("Sorry,this product is not available"); } public static void SelectProducts(ArrayList<Product> list,int productsID) { System.out.println(list.toString()); for(int i =0; i<list.size();i++) { int currentProductID= list.get(i).getproductsID(); if(productsID==currentProductID) { System.out.println("we have this product with id = " + currentProductID); return; } } System.out.println("Sorry but this product ID is wrong"); } } ايه حل الشمكلة
  10. بحتاج من المستخدم انو بيدخل ID تبع المنتج اللي يبا يختاروا وعملت ميثود ولكن لاتعمل ايه التعديل الي اعلموا public static void SelectProducts(ArrayList<Product> list,int productsID) { System.out.println( list.toString()); for(int i =0; i<list.size();i++) { System.out.println( "enter the ID number of the product you want, and when you finish selecting orders, please choose 0 "); int currentProductID= list.get(i).getproductsID(); if(productsID==currentProductID) { return; } System.out.println("Sorry but this product ID is wrong"); if(currentProductID==0) { break; } } }
  11. ArrayList<Product> list = Product.Search("productsName",list); بستدعي الميثود بالطريقة ذي صح؟
  12. عملت ميثود في كلاس للعملية search ولكن في main class عند الاستدعاء ما بتشتغل import java.util.ArrayList; import static pkgsuper.market.Product.Search; public class SuperMarket { public static void main(String[] args) { ArrayList<Product> list = new ArrayList<>(); Product p1 = new Product("Apple","fruits",347685,39); Product p2 = new Product("carrot","vegetables",354305,39); Product p3 = new Product("tea","herbs",389545,39); list.add(p1); list.add(p2); list.add(p3); } } package pkgsuper.market; import java.util.ArrayList; public class Product { private String productsName; private String productsType; private int productsID; private double productsPrice; private Object list; public Product() { productsName= null; productsType= null; productsID = 0; productsPrice = 0.0; } public Product(String productsName,String productsType,int productsID,double productsPrice ) { this.productsName = productsName; this.productsType = productsType; this.productsID = productsID; this.productsPrice = productsPrice; } public void setproductsName(String productsName) { this.productsName = productsName; } public void setproductsType(String productsType) { this.productsType = productsType; } public void setproductsID(int productsID) { this.productsID = productsID; } public void setproductsPrice(int productsPrice) { this.productsPrice = productsPrice; } public String getproductsName() { return this.productsName; } public String getproductsType() { return this.productsType; } public int getproductsID() { return this.productsID; } public double getproductsPrice() { return this.productsPrice; } public String toString() { String str = "Products name : " + productsName + "\nProducts type: " + productsType + "\nProducts ID: " + productsID + "\n Products price: " + productsPrice; return str; } public static void Search(ArrayList<Product> list,String productsName) { for(int i =0; i<list.size();i++) { Product name = list.get(i); if(productsName.equals(list.get(i).getproductsName())) { System.out.println("This product is available"); } else { System.out.println("Sorry,this product is not available"); } } } }
  13. import java.util.ArrayList; public class SuperMarket { public static void main(String[] args) { Product[] vegetables= new Product[3]; vegetables[0] = new Product ("toomatoes","vegetables",35525,30); vegetables[1] = new Product ("onions","vegetables",39064,20); vegetables[2] = new Product ("carrots","vegetables",33987,25); Product[] fruits= new Product[3]; fruits[0] = new Product ("Apple","fruits",23469,35); fruits[1] = new Product ("banana","fruits",29064,29); fruits[2] = new Product ("orange","fruits",23987,15); System.out.println(fruits[1].toString()); } } public class Product { private String productsName; private String productsType; private int productsID; private double productsPrice; public Product() { productsName= null; productsType= null; productsID = 0; productsPrice = 0.0; } public Product(String productsName,String productsType,int productsID,double productsPrice ) { this.productsName = productsName; this.productsType = productsType; this.productsID = productsID; this.productsPrice = productsPrice; } public void setproductsName(String productsName) { this.productsName = productsName; } public void setproductsType(String productsType) { this.productsType = productsType; } public void setproductsID(int productsID) { this.productsID = productsID; } public void setproductsPrice(int productsPrice) { this.productsPrice = productsPrice; } public String getproductsName() { return this.productsName; } public String getproductsType() { return this.productsType; } public int getproductsID() { return this.productsID; } public double getproductsPrice() { return this.productsPrice; } public String toString() { String str = "Products name : " + productsName + "\nProducts type: " + productsType + "\nProducts ID: " + productsID + "\n Products price: " + productsPrice; return str; } } احتاج مساعدة في عمل ميثود ل search البحث باستخدام اسم المنتج او ID وميثود ل select وميثود ل order
  14. احتاج مساعده في عمل كلاس في برنامج جافا عباره عن مواصفات المنتجات من اسم ونوع وسعر و IDومن ثم اعمل arraylist من ال object وايضا بنفس الكلاس يكون في ميثود خاصة بعملية البحث عن منتج معين بالاسم او Id وميثود خاصة بعملية الشراء
×
×
  • أضف...