/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
5
6
7
8
9
10
11 @author
12
13
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){
19 super(name, itemType, date, claimedStatus);
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
42 for(int i = 0; i < checkCollectorName.length(); i++){
43
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
53 return "not a valid input";
54 }
55 }
56
57 public int getCollectorID(){
58 String stringID = collectorID+"";
59
60
61 if(stringID.length()==5){
62 return collectorID;
63 }else{
64 return -1;
65 }
66 }
67 }
68