/Users/johnr/Desktop/IA_14_-_Stage_P_Upload_all_2021-04-08/CSIA14829 - Jane April 6th/src/csia14829/FoundItem.java
 1 package csia14829;
 2 
 3 /*
 4  * To change this license header, choose License Headers in Project Properties.
 5  * To change this template file, choose Tools | Templates
 6  * and open the template in the editor.
 7  */
 8 
 9 /**
10  *
11  * @author 14829
12  */
13 // the FoundItem is a subclass of Item
14 public class FoundItem extends Item{
15     private String collectorName = "not set yet";
16     private int collectorID = -999;
17    
18     public FoundItem(String name, String itemType, String date, boolean claimedStatus, String collectorName, int collectorID){ //BarcodeGenerator barcode --> add this later
19         super(name, itemType, date, claimedStatus); //barcode --> add this later
20         this.claimedStatus = true;
21         this.collectorName = collectorName;
22         this.collectorID = collectorID;
23         
24     }
25     public FoundItem(){
26         
27     }
28     
29     /**
30      *
31      * @return
32      */
33     @Override
34     public boolean getClaimedStatus(){
35         return claimedStatus;
36     }
37     
38     public String getCollectorName(){
39         String checkCollectorName = collectorName;
40         boolean collectorNameValid = true;
41         // this is to check for a valid user input
42         for(int i = 0; i < checkCollectorName.length(); i++){
43             // iterating through each char in the string, checks if the char is an English alphabet or space
44             char notedChar = checkCollectorName.charAt(i);
45             if(!((notedChar >= 'a' && notedChar <= 'z') || (notedChar >= 'A' && notedChar <= 'Z') || notedChar == ' ')){
46                 collectorNameValid = false;
47             }
48         }
49         if(collectorNameValid == true){
50             return collectorName;
51         }else{
52             // error message
53             return "not a valid input";
54         }
55     }
56     
57     public int getCollectorID(){
58         String stringID = collectorID+"";
59         // this checks for valid user input
60         // when made to String, needs to be of length 5
61         if(stringID.length()==5){
62             return collectorID;
63         }else{
64             return -1;
65         }
66     }
67 }
68