Hello,
I am new to this and even I was trying something like this , I have code with me that is somewhat similar to this. If you need you can find it helpful.
Here is the code:
Code:
Public Product(n String,double cpdouble pi, double num, String D) {
name = n;
PrixAchat = cp;
PrixVente = pi;
NbreExplStock = num;
des = D;
}
/ / method that returns me the des
Public String returnDescription(){
return des;
}
/ / Method that adds a product in my picture
Public void atpr(String name,double PrixAchat, double PrixVente, double num, String Desc) {
if (NB! = StockProduit.length){
StockProduit[NB] = new Product(name, PrixAchat, PrixVente, num, Desc);
NB + +;
}else{
System.out.System.out.println("Error, size of the array too small");
}
}
/ / Method to search by keyword
Public void rcprt(String word){
for(int i =0; i <NB; i + +){
if (StockProduit[i].returnDescription().regionMatches(true,0word,0word.length())){
System.out.System.out.println(word);
}
}
}
/ / and test
Mag mag new Mag();
mag.atpr("Eraser",3,5.2,3,"This product from our store");
mag.rcprt("Product");
Bookmarks