Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SY_77_Public Welfare #8

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
185 changes: 185 additions & 0 deletions 77-Community Event scheduler/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
package Buffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);

int ch,a,b,x,d,f,h,j,n,m;

String u,p,c,z,menu,ch1,menu1;
boolean flag = false;
String uorg="Anushree";
String porg="saga123";
//signUp s=new signUp();
logins l=new logins();
pQueue pQ=new pQueue();
System.out.println("Select Your Role ");
System.out.println("1]Admin\n2]User");
a=sc.nextInt();
switch(a)
{
case 1:
do {
System.out.println("Enter your username and password");
u=sc.next();
System.out.println("Enter your Password");
p=sc.next();
if(u.equals(uorg)&& p.equals(porg))
{
System.out.println("Welcome Admin");
flag=true;
}
else
System.out.println("Wrong pasword or username please try again");

}
while(flag==false);
do {
System.out.println("HELLO ADMIN!");
System.out.println("**********************MENU*******************");
System.out.println("1]View planned events\n2]Append event list");
m=sc.nextInt();
switch(m)
{

case 1:

pQ.dispadmin();
break;


case 2:


pQ.addJan();


break;
}
System.out.println("Return back to menu?");
menu1=sc.next();
}

while(menu1.equals("yes"));

break;


case 2:
do{
System.out.println("Press 1 to login and 2 to Signup");
ch=sc.nextInt();

switch(ch)
{
case 1:

while(true) {
System.out.println("Enter username: ");
String usernames = sc.next();
System.out.println("Enter password: ");
String passwords= sc.next();
if (l.authenticate(usernames, passwords)) {
System.out.println("Authentication successful! Welcome, " + usernames + "!");
break;
} else {
System.out.println("Invalid username or password. Please try again.");
}

}
do {
System.out.println("WELCOME!");
System.out.println("Please select one of the following preferences");
System.out.println("1]View the Events\n2]Do give us your feedback\n3]We accept donations");
int logch=sc.nextInt();
switch(logch)
{
case 1:
pQ.displayPQ();

break;
case 2:

System.out.println("Please provide your rating (1-5): ");
int rating = sc.nextInt();


sc.nextLine();
System.out.println("Please provide your comments: ");
String comments = sc.nextLine();

feedback feedback = new feedback(rating, comments);


System.out.println("\nThank you for your feedback:");
feedback.displayFeedback();
break;
case 3:
System.out.println("Would you like to donate cash? (yes/no)");
String response = sc.next();
double amount,donations=10000;
if (response.equals("yes")) {
// If yes, prompt for the amount
System.out.println("How much would you like to donate?");
amount = sc.nextDouble();
System.out.println("Thank you for donating Rs. " + amount);
donations=donations+amount;
// Here you can proceed with further actions like processing the donation
} else if (response.equals("no")) {
System.out.println("Thank you for considering!");
} else {
System.out.println("Invalid response. Please enter 'yes' or 'no'.");
}
System.out.println("Donations received uptil now "+donations);



break;
}
System.out.println("Return back to menu?");
menu=sc.next();

}while(menu.equals("yes"));

break;
case 2:

System.out.println("Welcome to the Sign-up Page");
Boolean continues=true;
while (continues) {
System.out.println("Enter username: ");
String username = sc.next();

System.out.println("Enter password: ");
String password = sc.next();

boolean success = l.signUp(username, password);
System.out.println("Do you want to sign up another user? (yes/no): ");
String input = sc.next();
if (input.equals("no")) {
continues= false;
}
}
break;
}
System.out.println("Do you wish to continue?");
ch1=sc.next();
} while(ch1.equalsIgnoreCase("yes"));





}
System.out.println("THANKYOU!DO VISIT AGAIN");
}
}





1 change: 1 addition & 0 deletions 77-Community Event scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

29 changes: 29 additions & 0 deletions 77-Community Event scheduler/event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Buffer;

public class event implements Comparable<event>{
int date;
String name;
String location;
public event(int date,String name,String location) {
this.name=name;
this.date = date;
this.location=location;
}

@Override
public int compareTo(event o) {
// TODO Auto-generated method stub
if(date<o.date)
return -1;
if(date>o.date)
return 1;
return 0;
}

public String toString()
{
String result="Event:" +name+" Date-"+date+" Location-"+location;
return result;
}
}

19 changes: 19 additions & 0 deletions 77-Community Event scheduler/feedback.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package Buffer;

public class feedback {

private int rating;
private String comments;

// Constructor
public feedback(int rating, String comments) {
this.rating = rating;
this.comments = comments;

}
public void displayFeedback() {
System.out.println("Rating: " + rating);
System.out.println("Comments: " + comments);
}
}

22 changes: 22 additions & 0 deletions 77-Community Event scheduler/logins.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package Buffer;

public class logins extends signUp{
/* public void authenticate(String usernames, String passwords) {
// Check if the username exists in the HashMap
if (users.containsKey(usernames)) {
//String p=users.get(usernames);
//if(p.equals(passwords))
//{
//System.out.println("login succuessful!");
//}
}*/
public boolean authenticate(String username, String password) {
if (users.containsKey(username)) {
return users.get(username).equals(password);
}
return false;
}


}

137 changes: 137 additions & 0 deletions 77-Community Event scheduler/pQueue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package Buffer;
import java.util.*;
import Buffer.event;

public class pQueue {
static ArrayList <user> cleanupdrive11List=new ArrayList<>();
static ArrayList <user> treeplantationdrive20List=new ArrayList<>();
static PriorityQueue<event> pqJan=new PriorityQueue<>();

public static void addJan(){
Scanner sc=new Scanner(System.in);
String b;
String a;
String z;
String y;
int x;
int c;




do {
System.out.println("Do you wish to insert more events say yes or no");
a=sc.next();
if(a.equals("yes"))
{
System.out.println("Enter the event");
z=sc.next();
System.out.println("Enter the date");
x=sc.nextInt();
System.out.println("Enter the location");
y=sc.next();

pqJan.add(new event(x,z,y));

}
}while (a.equals("yes"));
dispadmin() ;
}
public static void displayPQ() {
pqJan.add(new event(11,"Cleanup-Drive","Bhusari Colony"));
pqJan.add(new event(20,"Tree Plantation Drive","ARAI "));
Scanner sc=new Scanner(System.in);
Iterator itr=pqJan.iterator();
System.out.println("Following are the events ");
while(itr.hasNext())
{
System.out.println(pqJan.poll().toString());
}
System.out.println("Do you wish to register for any of these");
String choice=sc.next();
if(choice.equalsIgnoreCase("yes"))
{
System.out.println("Please enter the event number");
int event=sc.nextInt();
if(event==1) {
System.out.println("Enter email: ");
String email = sc.next();
System.out.println("Enter name: ");
String name = sc.next();
System.out.println("Enter surname: ");
String surname = sc.next();
System.out.println("Enter phone number: ");
double phoneNumber = sc.nextDouble();
user user1=new user(email, name, phoneNumber,surname);
cleanupdrive11List.add(user1);
System.out.println("Person registered successfully!");
}
else if(event==2) {
System.out.println("Enter email: ");
String email = sc.next();
System.out.println("Enter name: ");
String name = sc.next();
System.out.println("Enter surname: ");
String surname = sc.next();
System.out.println("Enter phone number: ");
double phoneNumber = sc.nextDouble();
user user1=new user(email, name, phoneNumber,surname);
treeplantationdrive20List.add(user1);
System.out.println("Person registered successfully!");
}
}

}

public static void displayCleanup() {
cleanupdrive11List.add(new user("[email protected]","Anu",34567765,"Bobde"));
cleanupdrive11List.add(new user("[email protected]","Anushree",345678765,"Bomble"));
Iterator list= cleanupdrive11List.iterator();
System.out.println("Following are the names of registered people for Cleanup Drive ");
while(list.hasNext())
{
user n=(user) list.next();
System.out.println(n.toString());
}
}

public String toString(String email, String name, double phoneNumber,String surname)
{

return "Email: " + email + ", Name: " + name + ", Phone Number: " + phoneNumber + ", Surname: " + surname;


}
public static void displayTreeplatation() {
treeplantationdrive20List.add(new user("[email protected]","Anu",34567765,"Bobde"));
treeplantationdrive20List.add(new user("[email protected]","Anushree",345678765,"Bomble"));
Iterator list= treeplantationdrive20List.iterator();
System.out.println("Following are the names of registered people for Tree Plantation Drive ");
while(list.hasNext())
{

user n=(user) list.next();
System.out.println(n.toString());
}
}

public static void dispadmin() {
pqJan.add(new event(11,"Cleanup-Drive","Bhusari Colony"));
pqJan.add(new event(20,"Tree Plantation Drive","ARAI "));
Scanner sc=new Scanner(System.in);
Iterator itr=pqJan.iterator();
System.out.println("Following are the events ");
while(itr.hasNext())
{
System.out.println(pqJan.poll().toString());
}
}
}








Loading