Answer To: See photos
Aditi answered on Sep 30 2022
REPORT
Part 1
1. One, I have experience in Java++, Python, JS, Spring, and Hibernate, among other languages and frameworks.
2. I have decided to choose the GitHub project based upon Hotel Management in Java.
The link of the project is https://github.com/shouryaj98/Hotel-Management-Project-Java.
In this project we are showing:
Guests' information may be stored, four distinct room types reserved, individual room service ordered, rooms released, and final charges shown with the help of this hotel management system. Room attributes and availability may be seen as well. It's a menu-based app that stays active until the user closes it. We've made use of file handling to save the hotel's current state (customer information, booked rooms, and food orders) when the application ends, so that we can access it upon program restart without losing any of the previously saved data. When the software is restarted, it checks the file to see what the hotel's status was before. Since file writing may be done in parallel, it has been handled in its own thread. If a user attempts to reserve a room that has already been reserved, a custom exception is raised. In the event of an unexpected occurrence, exceptions are handled correctly.
Classes, Objects, Inheritance, Working with Files Using Objects, Array List, Implementing an Interface, User-Defined Exceptions, and Handling Exceptions are some of the topics we'll be covering.
The project has 134 stars and 226 forks.
3. The project will help us to manage the hotel properly through an automatic management system.
a. The size of the project is: 20KB and age is : 5 years
b. The number of commits is: 9
Along with 134 stars and 226 forks.
c. Socio-Technical impact: Technology has made it possible to save expenses, increase operational efficiency, improve services, and provide a better experience for customers. Customers and companies alike stand to gain from streamlined communication, reservation, and customer service software and hardware.
i. It is a tool for other developers to enhance their services by providing better facilities in their hotel management system and rise as a better competitor.
d. Some of the best practices for the newcomers can be to design this system in much more efficient manner with all the graphics and animations which will make it more appealing and attractive because hotel industry runs on the basis of customers. The more presentable we are the more audience we can grab.
e. Some of the best practices are:
i. Code of conduct: Make a positive impact on both society and individual lives by contributing. Programmers should strive to design computer systems that can lessen the bad effects on society, such as risks to people's health and safety, and that can make day-to-day tasks and work more manageable.
ii. Pull requests:
· Consider the time of others.
· Never provide negative criticism.
· Code reviews are no place for egos.
· Identify the Specific Areas That Require Enhancement.
· Don't Bank on the Code Being Effective.
· Best practices for submitting code should be reinforced.
· Don't be lenient with short-term code.
iii. Code style:
· Get your point over in as few words as feasible.
· Please use standard naming practices.
· Break up large chunks of code that belong together into paragraphs.
· Make sure to indent the beginning and ending of any control structures you use.
· Try to avoid using long functions.
· Stick to the DRY (Don't Repeat Yourself) rule.
· Strive to avoid becoming too comfortable in your nest.
iv. Anything else! We should be attentive while we are coding and try to make sure that we get the right thing at the very first time.
4. a. There is issue in this project as it is taking any number of digits contact number and even, we are able to type any gender.
b. The technology involved is Java.
c. It will take 4 hours to fix the change along with proper testing of the code.
d. We are doing this so that the project is more user friendly and the customer can feed in proper details.
Part 2
1. We will try to fix the issue of excepting any gender and characters along with this we will fix the issue of contact number which should be integer and should be of 10 digits.
2. We will abide by the contribution guidelines by taking proper approval from the creator and then providing our fix.
3. We will implement our changes in a way that the project code will not be hampered, and our fix will work seamlessly after the work done.
i. I have added proper functionality in the code that will check the contact number and gender properly.
ii. Previous code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Scanner;
class Food implements Serializable
{
int itemno;
int quantity;
float price;
Food(int itemno,int quantity)
{
this.itemno=itemno;
this.quantity=quantity;
switch(itemno)
{
case 1:price=quantity*50;
break;
case 2:price=quantity*60;
break;
case 3:price=quantity*70;
break;
case 4:price=quantity*30;
break;
}
}
}
class Singleroom implements Serializable
{
String name;
String contact;
String gender;
ArrayList food =new ArrayList<>();
Singleroom()
{
this.name="";
}
Singleroom(String name,String contact,String gender)
{
this.name=name;
this.contact=contact;
this.gender=gender;
}
}
class Doubleroom extends Singleroom implements Serializable
{
String name2;
String contact2;
String gender2;
Doubleroom()
{
this.name="";
this.name2="";
}
Doubleroom(String name,String contact,String gender,String name2,String contact2,String gender2)
{
this.name=name;
this.contact=contact;
this.gender=gender;
this.name2=name2;
this.contact2=contact2;
this.gender2=gender2;
}
}
class NotAvailable extends Exception
{
@Override
public String toString()
{
return "Not Available !";
}
}
class holder implements Serializable
{
Doubleroom luxury_doublerrom[]=new Doubleroom[10]; //Luxury
Doubleroom deluxe_doublerrom[]=new Doubleroom[20]; //Deluxe
Singleroom luxury_singleerrom[]=new Singleroom[10]; //Luxury
Singleroom deluxe_singleerrom[]=new Singleroom[20]; //Deluxe
}
class Hotel
{
static holder hotel_ob=new holder();
static Scanner sc = new Scanner(System.in);
static void CustDetails(int i,int rn)
{
String name, contact, gender;
String name2 = null, contact2 = null;
String gender2="";
System.out.print("\nEnter customer name: ");
name = sc.next();
System.out.print("Enter contact number: ");
contact=sc.next();
System.out.print("Enter gender: ");
gender = sc.next();
if(i<3)
{
System.out.print("Enter second customer name: ");
name2 = sc.next();
System.out.print("Enter contact number: ");
contact2=sc.next();
System.out.print("Enter gender: ");
gender2 = sc.next();
}
switch (i) {
case 1:hotel_ob.luxury_doublerrom[rn]=new Doubleroom(name,contact,gender,name2,contact2,gender2);
break;
case 2:hotel_ob.deluxe_doublerrom[rn]=new Doubleroom(name,contact,gender,name2,contact2,gender2);
break;
case 3:hotel_ob.luxury_singleerrom[rn]=new Singleroom(name,contact,gender);
break;
case 4:hotel_ob.deluxe_singleerrom[rn]=new Singleroom(name,contact,gender);
break;
default:System.out.println("Wrong option");
break;
}
}
static void bookroom(int i)
{
int j;
int rn;
System.out.println("\nChoose room number from : ");
switch (i) {
case 1:
for(j=0;j {
if(hotel_ob.luxury_doublerrom[j]==null)
{
System.out.print(j+1+",");
}
}
System.out.print("\nEnter room number: ");
try{
rn=sc.nextInt();
rn--;
if(hotel_ob.luxury_doublerrom[rn]!=null)
throw new NotAvailable();
CustDetails(i,rn);
}
catch(Exception e)
{
System.out.println("Invalid Option");
return;
}
break;
case 2:
for(j=0;j {
if(hotel_ob.deluxe_doublerrom[j]==null)
{
System.out.print(j+11+",");
}
}
System.out.print("\nEnter room number: ");
try{
rn=sc.nextInt();
rn=rn-11;
if(hotel_ob.deluxe_doublerrom[rn]!=null)
throw new NotAvailable();
CustDetails(i,rn);
}
catch(Exception e)
{
System.out.println("Invalid Option");
return;
}
break;
case 3:
for(j=0;j {
if(hotel_ob.luxury_singleerrom[j]==null)
{
System.out.print(j+31+",");
}
}
System.out.print("\nEnter room number: ");
try{
rn=sc.nextInt();
rn=rn-31;
if(hotel_ob.luxury_singleerrom[rn]!=null)
throw new NotAvailable();
CustDetails(i,rn);
}
catch(Exception e)
{
System.out.println("Invalid Option");
return;
}
break;
case 4:
for(j=0;j {
if(hotel_ob.deluxe_singleerrom[j]==null)
{
System.out.print(j+41+",");
}
}
System.out.print("\nEnter room number: ");
try{
rn=sc.nextInt();
rn=rn-41;
if(hotel_ob.deluxe_singleerrom[rn]!=null)
throw new NotAvailable();
CustDetails(i,rn);
}
catch(Exception e)
{
System.out.println("Invalid Option");
return;
}
break;
default:
System.out.println("Enter valid option");
break;
}
System.out.println("Room Booked");
}
static void features(int i)
{
switch (i) {
case 1:System.out.println("Number of double beds : 1\nAC : Yes\nFree breakfast : Yes\nCharge per day:4000 ");
break;
case 2:System.out.println("Number of double beds : 1\nAC : No\nFree breakfast : Yes\nCharge per day:3000 ");
break;
case 3:System.out.println("Number of single beds : 1\nAC : Yes\nFree breakfast : Yes\nCharge per day:2200 ");
break;
case 4:System.out.println("Number of single beds : 1\nAC : No\nFree breakfast : Yes\nCharge per day:1200 ");
break;
default:
System.out.println("Enter valid option");
break;
}
}
static void availability(int i)
{
int j,count=0;
switch (i) {
case 1:
for(j=0;j<10;j++)
{
if(hotel_ob.luxury_doublerrom[j]==null)
count++;
}
break;
case 2:
for(j=0;j {
if(hotel_ob.deluxe_doublerrom[j]==null)
count++;
}
break;
case 3:
for(j=0;j {
if(hotel_ob.luxury_singleerrom[j]==null)
count++;
}
break;
case 4:
for(j=0;j {
if(hotel_ob.deluxe_singleerrom[j]==null)
count++;
}
break;
default:
System.out.println("Enter valid option");
break;
}
System.out.println("Number of rooms available : "+count);
}
static void bill(int rn,int rtype)
{
double amount=0;
String list[]={"Sandwich","Pasta","Noodles","Coke"};
System.out.println("\n*******");
System.out.println(" Bill:-");
System.out.println("*******");
switch(rtype)
{
case 1:
amount+=4000;
System.out.println("\nRoom Charge - "+4000);
System.out.println("\n===============");
System.out.println("Food Charges:- ");
System.out.println("===============");
System.out.println("Item Quantity Price");
System.out.println("-------------------------");
for(Food obb:hotel_ob.luxury_doublerrom[rn].food)
{
amount+=obb.price;
...