From 9845b0c2afd78553cd55cf225b19edf6e6881b0a Mon Sep 17 00:00:00 2001 From: KetakiSane <79862061+KetakiSane@users.noreply.github.com> Date: Sat, 5 Jun 2021 13:05:03 +0530 Subject: [PATCH 01/10] Add files via upload --- Al.java | 137 +++++++++++++++++++++ Al2.java | 76 ++++++++++++ AlAl.java | 36 ++++++ Entry Records.txt | 11 ++ Entry.java | 22 ++++ Entry2.java | 23 ++++ FileToAl.java | 78 ++++++++++++ Guest.java | 97 +++++++++++++++ HashMap.java | 101 ++++++++++++++++ HashMap2.java | 102 ++++++++++++++++ Househelpers data.txt | 22 ++++ Key.java | 65 ++++++++++ Key2.java | 57 +++++++++ Residents data.txt | 73 +++++++++++ SocietyEntrance.java | 273 ++++++++++++++++++++++++++++++++++++++++++ Value.java | 63 ++++++++++ Value2.java | 33 +++++ 17 files changed, 1269 insertions(+) create mode 100644 Al.java create mode 100644 Al2.java create mode 100644 AlAl.java create mode 100644 Entry Records.txt create mode 100644 Entry.java create mode 100644 Entry2.java create mode 100644 FileToAl.java create mode 100644 Guest.java create mode 100644 HashMap.java create mode 100644 HashMap2.java create mode 100644 Househelpers data.txt create mode 100644 Key.java create mode 100644 Key2.java create mode 100644 Residents data.txt create mode 100644 SocietyEntrance.java create mode 100644 Value.java create mode 100644 Value2.java diff --git a/Al.java b/Al.java new file mode 100644 index 0000000..f315637 --- /dev/null +++ b/Al.java @@ -0,0 +1,137 @@ +package logic; +import java.util.Arrays; + //import java.util.Scanner; + public class Al + { + private static final int INITIAL_CAPACITY = 5; + private int size ; + private String[] elementData ; + //private String elementData[20]; + + public Al() { + + this.elementData= new String[INITIAL_CAPACITY]; + //this.elementData[0]="abc"; + //this.elementData[1]="xyz"; + for(int i=0;this.elementData[i]!=null;i++) + size=i+1; + } + + + public void add(String name) { + + if ( size == elementData.length) { + ensureCapacity(); // increase current capacity of list, make it + // double. + } + + this.elementData[size++] = name; + } + + public String remove(String in) { + + int j=0,flag=1; + for( j=0;j25||gflat<1));//condition for while loop + this.flatNumber=Integer.toString(gflat); + } + + @Override + public String toString() {//for displaying + return "\nGuest Name: "+ name +"\t\tPhone no: "+ phoneNumber +" FlatNo: "+ flatNumber +" Date & Time: "+ formattedDate +" \n"; + + } + +} diff --git a/HashMap.java b/HashMap.java new file mode 100644 index 0000000..ca71312 --- /dev/null +++ b/HashMap.java @@ -0,0 +1,101 @@ +package logic; +import java.util.*; + + +public class HashMap { + @SuppressWarnings("unchecked") + LinkedList[] hashmap = new LinkedList[2]; + int size=0;//size==hashmap.length() !=hashmap.length + public HashMap() { + + } + public int getIndex(Key key) {//getter method for Index + return key.hashCode(); + } + + public int size() {//method that returns size + return size; + } + + @SuppressWarnings("unchecked") + public void resize() { + LinkedList[] oldhashmap = hashmap; + hashmap = new LinkedList[size*2];//Creating a new LinkedList of double size + size = 0; + for(int i=0;i=hashmap.length) { + resize();//call to resize function when threshold is reached + } + int ix=getIndex(key)%hashmap.length; + if(hashmap[ix]==null) { + hashmap[ix] = new LinkedList<>();//creating a new LinkedList + hashmap[ix].add(new Entry(key, value)); + size++; //Increasing size after adding elements + return; + } + else { + for(Entry entry : hashmap[ix]) { + if(entry.key.equals(key)) { + entry.value = value;//updating value + //size++; + return; + } + } + hashmap[getIndex(key)%hashmap.length].add(new Entry(key, value));//adding elements without replacement + //no size++ because we are adding a node to the existing linked list at [ix] calculated + //and not adding a diff linked list + return; + } + + } + + public Value get(Key key) { + int ix= getIndex(key)%this.hashmap.length; + if(this.hashmap[ix] ==null) { + return null; + } + + for(int j=0;j[] hashmap2 = new LinkedList[2]; + int size=0;//size==hashmap.length() !=hashmap.length + public HashMap2() { + + } + public int getIndex(Key2 key2) { + return key2.hashCode()&0x7FFFFFFF; + } + + public int size() { + return size; + } + + //@SuppressWarnings("unchecked")///////////////////////////////// + public void resize() { + LinkedList[] oldhashmap2 = hashmap2; + hashmap2 = new LinkedList[size*2]; + size = 0; + for(int i=0;i=hashmap2.length) { + resize(); + } + int ix=getIndex(key2)%hashmap2.length; + if(hashmap2[ix]==null) { + hashmap2[ix] = new LinkedList<>(); + hashmap2[ix].add(new Entry2(key2, value2)); + size++; + return; + } + else { + for(Entry2 entry2 : hashmap2[ix]) { + if(entry2.key2.equals(key2)) { + entry2.value2 = value2; + //size++; + return; + } + } + hashmap2[getIndex(key2)%hashmap2.length].add(new Entry2(key2, value2)); + //no size++ because we are adding a node to the existing linked list at [ix] calculated + //and not adding a diff linked list + return; + } + + } + + public Value2 get(Key2 key2) { + int ix= getIndex(key2)%this.hashmap2.length; + if(this.hashmap2[ix] ==null) { + return null; + } + + for(int j=0;j 5); + + boolean found1=false; + for(int i=0;i 5); + return ch; + } + + public static void createMap(Al flatNos, Al2 values, HashMap map) + { //Mapping flat nos to resident data + for (int i = 0; i < flatNos.getSize(); i++) + { + Key key = new Key(); + key.flatNumber = flatNos.getString(i); + map.put(key, values.getValues(i)); + } + } + + public static String permission(Guest g) // getting permission from resident + { + Scanner sc = new Scanner(System.in); + String approved; + System.out.println( + g.getName() + " wants to meet you.\nEnter '1' if the person is your guest, else enter any other key"); + approved=sc.nextLine(); + return approved; + } + + public static void createMap2(Al hnames_type, AlAl fnos, HashMap2 map2) + { //Mapping house helpers to flat nos they work in + for (int i = 0; i < hnames_type.getSize(); i++) + { + Key2 key2 = new Key2(); + key2.hname_type = hnames_type.getString(i); + map2.put(key2, fnos.getValues2(i)); + } + + } +} diff --git a/Value.java b/Value.java new file mode 100644 index 0000000..7925baf --- /dev/null +++ b/Value.java @@ -0,0 +1,63 @@ +package logic; + +import java.util.Objects; + +public class Value { + + private Al familyMembers;//ArrayList for Names of Family Members + private Al phoneNumbers;//ArrayList for Phone Numbers of Family Members + + public Value(Al familyMembers, Al phoneNumbers) {//parameterized constructor + this.familyMembers = familyMembers; + this.phoneNumbers = phoneNumbers; + } + + public Value() {//default constructor + this.familyMembers = null; + this.phoneNumbers = null; + } + + public Al getFamilyMembers() { + return familyMembers; + } + + public Al getPhoneNumbers() { + return phoneNumbers; + } + + /*@Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((familyMembers == null) ? 0 : familyMembers.hashCode()); + result = prime * result + ((phoneNumbers == null) ? 0 : phoneNumbers.hashCode()); + return result; + }*/ + + /*@Override + public int hashCode() { + return Objects.hash(familyMembers, phoneNumbers); + }*/ + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Value)) { + return false; + } + Value other = (Value) obj; + return Objects.equals(familyMembers, other.familyMembers) && Objects.equals(phoneNumbers, other.phoneNumbers); + } + + @Override + public String toString() {//Used for Displaying the information of the family + return "Value [familyMembers=" + familyMembers + ", phoneNumbers=" + phoneNumbers + "]"; + } + + + +} + + \ No newline at end of file diff --git a/Value2.java b/Value2.java new file mode 100644 index 0000000..32fa151 --- /dev/null +++ b/Value2.java @@ -0,0 +1,33 @@ +package logic; + +import java.util.Objects; + +public class Value2 { + public Al hfnos; + + public Value2(Al hfnos) {//parameterized constructor + this.hfnos = hfnos; + } + + public Value2() {//default constructor + this.hfnos = null; + } + + + public Al getHfnos() { + return hfnos; + } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Value2)) { + return false; + } + Value2 other = (Value2) obj; + return Objects.equals(hfnos, other.hfnos);//returning boolean value + } + + +} From dfb78cd288c5330af1df12ab955160954cfceac5 Mon Sep 17 00:00:00 2001 From: KetakiSane <79862061+KetakiSane@users.noreply.github.com> Date: Sat, 5 Jun 2021 13:39:14 +0530 Subject: [PATCH 02/10] Add files via upload --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index e674b94..39c4751 100644 --- a/README.md +++ b/README.md @@ -1,5 +1 @@ -# Buffer_2.0 -Buffer_2.0 repo to submit your projects to.Repository containing folder-wise code for all submissions to Buffer : A Project Series, conducted between April, 2021 - June, 2020. - -Each folder should contain a separate README to describe the files and project objective - +Housing Security Management System From 041487baf70ac85e070e4e56157fcae7dc151996 Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Sat, 5 Jun 2021 21:54:33 +0530 Subject: [PATCH 03/10] Update Al2.java --- Al2.java | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/Al2.java b/Al2.java index 2af8e96..d887773 100644 --- a/Al2.java +++ b/Al2.java @@ -25,48 +25,12 @@ public void add(Value obj) { - /*public Value remove(String in) { - - int j=0,flag=1; - for( j=0;j Date: Sat, 5 Jun 2021 21:55:48 +0530 Subject: [PATCH 04/10] Update Al.java --- Al.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Al.java b/Al.java index f315637..227d7d6 100644 --- a/Al.java +++ b/Al.java @@ -1,18 +1,16 @@ package logic; import java.util.Arrays; - //import java.util.Scanner; + public class Al { private static final int INITIAL_CAPACITY = 5; private int size ; private String[] elementData ; - //private String elementData[20]; + public Al() { this.elementData= new String[INITIAL_CAPACITY]; - //this.elementData[0]="abc"; - //this.elementData[1]="xyz"; for(int i=0;this.elementData[i]!=null;i++) size=i+1; } From cee50642a27309e501a2e09638fc2bde9a3eac8f Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Sat, 5 Jun 2021 21:59:06 +0530 Subject: [PATCH 05/10] Update HashMap2.java --- HashMap2.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HashMap2.java b/HashMap2.java index af63e1a..53e2e52 100644 --- a/HashMap2.java +++ b/HashMap2.java @@ -2,10 +2,10 @@ import java.util.*; -//import java.lang.*; + public class HashMap2 { - //@SuppressWarnings("unchecked")////////////////////////////// + LinkedList[] hashmap2 = new LinkedList[2]; int size=0;//size==hashmap.length() !=hashmap.length public HashMap2() { @@ -19,7 +19,7 @@ public int size() { return size; } - //@SuppressWarnings("unchecked")///////////////////////////////// + public void resize() { LinkedList[] oldhashmap2 = hashmap2; hashmap2 = new LinkedList[size*2]; From 6e412fe630faeeab8b54fe2b52ccef5174d93858 Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Sat, 5 Jun 2021 21:59:45 +0530 Subject: [PATCH 06/10] Update Key.java --- Key.java | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/Key.java b/Key.java index aa3f582..5f8a39e 100644 --- a/Key.java +++ b/Key.java @@ -33,32 +33,6 @@ public boolean equals(Object obj) { return Objects.equals(flatNumber, other.flatNumber); } - /*@Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((flatNumber == null) ? 0 : flatNumber.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Key)) { - return false; - } - Key other = (Key) obj; - if (flatNumber == null) { - if (other.flatNumber != null) { - return false; - } - } else if (!flatNumber.equals(other.flatNumber)) { - return false; - } - return true; - }*/ From a68b2ae3a9768d89e97cba387a59b4558e56632c Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Sat, 5 Jun 2021 22:00:10 +0530 Subject: [PATCH 07/10] Update Key2.java --- Key2.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Key2.java b/Key2.java index 7c8cda5..5717311 100644 --- a/Key2.java +++ b/Key2.java @@ -34,23 +34,6 @@ public boolean equals(Object obj) { return Objects.equals(hname_type, other.hname_type); } - /*@Override - public int hashCode() { - return Objects.hash(hname_type); - } - - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Key2)) { - return false; - } - Key2 other = (Key2) obj; - return Objects.equals(hname_type, other.hname_type); - }*/ From 7350cec0c2365f8c045b712021175836ab260d1e Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Sat, 5 Jun 2021 22:00:41 +0530 Subject: [PATCH 08/10] Update Value.java --- Value.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Value.java b/Value.java index 7925baf..44b2e62 100644 --- a/Value.java +++ b/Value.java @@ -25,20 +25,9 @@ public Al getPhoneNumbers() { return phoneNumbers; } - /*@Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((familyMembers == null) ? 0 : familyMembers.hashCode()); - result = prime * result + ((phoneNumbers == null) ? 0 : phoneNumbers.hashCode()); - return result; - }*/ - - /*@Override - public int hashCode() { - return Objects.hash(familyMembers, phoneNumbers); - }*/ + + @Override public boolean equals(Object obj) { if (this == obj) { @@ -60,4 +49,4 @@ public String toString() {//Used for Displaying the information of the family } - \ No newline at end of file + From 07e4a0984438f829846127b4164fc464fe93e4ce Mon Sep 17 00:00:00 2001 From: KetakiSane <79862061+KetakiSane@users.noreply.github.com> Date: Tue, 8 Jun 2021 18:48:37 +0530 Subject: [PATCH 09/10] Update README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 39c4751..3c73814 100644 --- a/README.md +++ b/README.md @@ -1 +1,25 @@ Housing Security Management System + + + +OBJECTIVE OF THE PROJECT:- + +a) The objective of our project is to make a system that would give all the essential security to a housing society. +b) Such a system that would identify residents as residents, housekeepers as housekeepers and would admit entry to a guest after ensuring all the necessary things. + + +DATA STRUCTURE USED IN THE PROJECT:- + +a) The main data structure used is the Hashmap. +b) We've also used file and arraylist. + + +WHAT DID YOU LEARN WHILE WORKING ON THIS PROJECT:- +a) How to use optimise a solution by using the best possible data structure. +b) Time Management and how to work efficiently with all the members of the team. + + + +WHAT'S NEXT FOR OUR PROJECT:- +-> We plan to make our project Graphical User Interface so that it would be more user friendly. + From 125d4784b33422ba58e34ccba531651b76002b6c Mon Sep 17 00:00:00 2001 From: ruujuutaa <79862024+ruujuutaa@users.noreply.github.com> Date: Tue, 8 Jun 2021 19:22:18 +0530 Subject: [PATCH 10/10] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c73814..f0d0a58 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ b) Time Management and how to work efficiently with all the members of the team. + WHAT'S NEXT FOR OUR PROJECT:- --> We plan to make our project Graphical User Interface so that it would be more user friendly. +-> We plan to make our project Graphical User Interface so that it would be more user friendly.We would like to add some more functionalities in the code. +Note: Please make sure you open the text files in the project folder and not in the source folder.You may get a File not found exception if you open it in the src folder.