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

حساب قيمة الفاتورة وطباعة المنتجات ومعلومات العميل بلغة جافا

RAA

السؤال

الكود

//Class customer
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Customer {

    
    
    String name;
    int number;
    String email;
  
    private String nameOfCustomer;
    private int phoneNumber;
    private String emailCustomer;

    public Customer() {
        this.nameOfCustomer="";
        this.phoneNumber=0;
        this.emailCustomer="";
        
    }

    public Customer(String nameOfCustomer, int phoneNumber, String emailCustomer) {
        this.nameOfCustomer = nameOfCustomer;
        this.phoneNumber = phoneNumber;
        this.emailCustomer = emailCustomer;
    }

    Customer(Customer customer0) {
        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
    }

    public String getNameOfCustomer() {
        return nameOfCustomer;
    }

    public int getPhoneNumber() {
        return phoneNumber;
    }

    public String getEmailCustomer() {
        return emailCustomer;
    }

    public void setNameOfCustomer(String nameOfCustomer) {
        this.nameOfCustomer = nameOfCustomer;
    }

    public void setPhoneNumber(int phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public void setEmailCustomer(String emailCustomer) {
        this.emailCustomer = emailCustomer;
    }
    
    public String toString(){
        String data;
        data="Customer name : "+this.nameOfCustomer+"\nCustomer phone number : "+this.phoneNumber+
                "\nCustomer email : "+this.emailCustomer;
        return data;
    }
    public void WritingInFile() throws IOException{
        FileWriter myFile= new FileWriter("Customer information.txt",true);
        PrintWriter write= new PrintWriter(myFile);
        
        write.print(this.nameOfCustomer+"\t");
        write.print(this.phoneNumber+"\t");
        write.print(this.emailCustomer+"\t");
        
        write.close(); 
    }
    
    public void displayInformation() throws FileNotFoundException{
        
        System.out.println("Customer name\t phone number\t Customer email");
        File file = new File("Customer information.txt");
        Scanner readIn = new Scanner(file);
        
        while(readIn.hasNext()){
            String line =readIn.nextLine();
            System.out.println(line);
        }
        readIn.close();
    }
}









import java.util.ArrayList;

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;
       
        
    }

   public static void creatInoices() {
        
        System.out.println("Thank you");
        

    }
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...