questi sono gli oggetti di libris:
questi i metodi :codice:public class libris { private String autore; private String titolo; private String genere; private double prezzo; private int copie; public libris(String autore,String titolo,String genere,double prezzo,int copie){ this.autore = autore; this.titolo = titolo; this.genere=genere; this.prezzo=prezzo; this.copie=copie; } public String getautore() { return autore; } public String gettitolo() { return titolo; } public String getgenere() { return genere; } public double getprice() { return prezzo; } public int getcopie(){ return copie; } }
codice:public class libro { public libris l[]=new libris[1000]; public void start() { for(int i=0;i<1000;i++){ l[i]=null; } public void pres(){ System.out.println("+-------------------------------+"); System.out.println("SOFTWARE DI GESTIONE PER LIBRERIE"); System.out.println("+-------------------------------+"); System.out.println("@COPYRIGHT BY PETRUZZI MATTEO & FALCO FEDERICO"); } public void addlibro (){ for(int i=0;i<1000;i++){ String nome,autore,genere; double prezzo; int copie=1; Scanner in=new Scanner(System.in); System.out.println("type the name's book: \n"); nome=in.nextLine(); System.out.println("type the autor's book: \n"); autore=in.nextLine(); System.out.println("type the genre's book: \n"); genere=in.nextLine(); System.out.println("type the price of the book: \n"); prezzo=in.nextDouble(); if((l[i].getautore().equals(autore))&&(l[i].getgenere().equals(genere))&&(l[i].gettitolo().equals(nome))) { copie=l[i].getcopie()+copie; l[i]=new libris(nome,autore,genere,prezzo,copie); } else{ l[i]=new libris(nome,autore,genere,prezzo,copie); } } } void search(){ Scanner in=new Scanner(System.in); System.out.println("type the name's book: \n"); String nome=in.nextLine(); for(int i=0;i<1000;i++){ if(l[i].gettitolo()==nome){ System.out.println("name's book: "+l[i].gettitolo()+"\n"); System.out.println("autor's book: "+l[i].getautore()+"\n"); System.out.println("genre's book: "+l[i].getgenere()+"\n"); System.out.println("price's book: "+l[i].getprice()+"\n"); System.out.println("price's book: "+l[i].getprice()+"\n"); } } } void rmvbook(){ String autore,genere; double prezzo; Scanner in=new Scanner(System.in); System.out.println("type the name's book: \n"); String nome=in.nextLine(); System.out.println("type the autor's book: \n"); autore=in.nextLine(); System.out.println("type the genre's book: \n"); genere=in.nextLine(); System.out.println("type the price of the book: \n"); prezzo=in.nextDouble(); int copie=1; for(int i=0;i<1000;i++){ if((l[i].gettitolo()==nome)&&(l[i].getcopie()!=1)&&(l[i].getautore()==autore)){ copie=l[i].getcopie()-copie; l[i]=new libris(nome,autore,genere,prezzo,copie); } if((l[i].gettitolo()==nome)&&(l[i].getcopie()==1)&&(l[i].getautore()==autore)){ l[i]=null; } } }

Rispondi quotando