Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution OOPs-Para-Constructor Java
Capgemini ADAPT Sprint 2 Case Study (Bus Reservation System) Solution OOPs-Para-Constructor Java

In this post, you will get the solution to the first problem of Capgemini ADAPT Sprint 2 –  Bus Reservation System JBR-CS5A-L3-2-OOPs-Para-Constructor.

Note: The solutions are provided for learning purposes only. 

Sprint 2 – Problem 1: JBR-CS5A-L3-2-OOPs-Para-Constructor:


Capgemini ADAPT Problem Description:


  1. Create the parameterized constructor to pass the values to the instance variables for Admin, Address, Customer & ServiceDetails and BookingDetails objects and display them. Create setter and getter methods for each of these classes as per the given structure.

Override toString() method to return all the fields using String concatenation for both BookingDetails and Customer class.

Sprint 2 HAS A Relationship Solution
Sprint 2 OOPs Para Constructor

Sample Output:


Customer[userid=1001, [email protected], [email protected], firstName=Raj, lastName=Kumar, city=Bangalore, gender=Male, phoneNo=123456789];

Execution Time Limit:


10 seconds

The solution to JBR-CS5A-L3-2-OOPs-Para-Constructor:


 

class Customer{
int userid;
String emailid;
String password;
String firstName;
String lastName;
String city;
String gender;
int phoneNo;

public Customer(){
super();
}

public Customer(int userid, String emailid, String password, String firstName, String lastName, String city, String gender, int phoneNumber){

this.userid = userid;
this.emailid = emailid;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.city = city;
this.gender = gender;
this.phoneNo = phoneNo;
}

public int getUserid(){
return this.userid;
}
public void setUserid(int userid){
this.userid = userid;
}

public String getEmailid(){
return this.emailid;
}
public void setEmailid(String emailid){
this.emailid = emailid;
}

public String getPassword(){
return this.password;
}
public void setPassword(String password){
this.password = password;
}

public String getFirstName(){
return this.firstName;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}

public String getLastName(){
return this.lastName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}

public String getCity(){
return this.city;
}
public String setCity(String city){
this.city = city;
}

public String getGender(){
return this.gender;
}
public String setGender(String gender){
this.gender = gender;
}

public int getPhoneNo(){
return this.phoneNo;
}
public void setPhoneNo(int phoneNo){
this.phoneNo = phoneNo;
}

@Override
public String toString(){
return "Customer [userid="+userid+", emailid="+emailid+", password="+password+", firstName="+firstName+", lastName="+lastName+", city="+city+", gender="+gender+", phoneNo="+phoneNo+"]";
}
}

class Address
{
String city;
String state;
int zip;
String country;

public Address(){
super();
}

public Address(String city, String state, int zip, String country){

super();
this.city = city;
this.state = state;
this.zip = zip;
this.country = country;
}

@Override
public String toString(){
return "Address [city="+city+", state="+state+", zip="+zip+", country="+country+"]";
}
}

class ServiceDetails
{
String serviceId;
String busId;
String deptDateTime;
String arrDateTime;
String arrivalCity;
String deptCity;
String cost;
String seatsLeft;
String totalSeats;

public ServiceDetails(){
super();
}

public ServiceDetails(String serviceId, String busId, String deptDateTime, String arrDateTime, String arrivalCity, String deptCity, String cost, String seatsLeft, String totalSeats){

super();
this.serviceId = serviceId;
this.busId = busId;
this.deptDateTime = deptDateTime;
this.arrDateTime = arrDateTime;
this.arrivalCity = arrivalCity;
this.deptCity = deptCity;
this.cost = cost;
this.seatsLeft = seatsLeft;
this.totalSeats = totalSeats;
}

public String getServiceId(){
return this.serviceId;
}
public void setServiceId(String serviceId){
this.serviceId = serviceId;
}

public String getBusId(){
return this.busId;
}
public void setBusId(String busId){
this.busId = busId;
}

public String getDeptDateTime(){
return this.deptDateTime;
}
public void setDeptDateTime(String deptDateTime){
this.deptDateTime = deptDateTime;
}

public String getArrDateTime(){
return this.arrDateTime;
}
public void setArrDateTime(String arrDateTime){
this.arrDateTime = arrDateTime;
}

public String getArrivalCity(){
return this.arrivalCity;
}
public void setArrivalCity(String arrivalCity){
this.arrivalCity = arrivalCity;
}

public String getDeptCity(){
return this.deptCity;
}
public void setDeptCity(String deptCity){
this.deptCity = deptCity;
}

public String getCost(){
return this.cost;
}
public void setCost(String cost){
this.cost = cost;
}

public String getSeatsLeft(){
return this.seatsLeft;
}
public void setSeatsLeft(String seatsLeft){
this.seatsLeft = seatsLeft;
}

public String getTotalSeats(){
return this.totalSeats;
}
public void setTotalSeats(String totalSeats){
this.totalSeats = totalSeats;
}

@Override
public String toString(){
return "ServiceDetails [serviceId="+serviceId+", busId="+busId+", deptDateTime="+deptDateTime+", arrDateTime="+arrDateTime+", arrivalCity="+arrivalCity+", deptCity="+deptCity+", cost="+cost+", seatsLeft="+seatsLeft+", totalSeats="+totalSeats+"]";
}
}

public class Source{
public static void main(String args[]){
Address address = new Address("Bangalore", "Karnataka", 123456, "India");
ServiceDetails serviceDetails = new ServiceDetails("SID1001", "BUS001", "10/01/2022", "15/01/2022", "Bangalore", "Delhi", "2500", "9", "70");
System.out.println(serviceDetails);
Customer customer = new Customer(1001, "[email protected]", "Password", "Raj", "Kumar", "Bangalore", "Male", 1234567890);
}
}

 

TOP COMPANIES HIRING DRIVE

BATCHWISE OFF-CAMPUS DRIVES

1. TCS OFF-CAMPUS DRIVES 1. 2018 BATCH
2. INFOSYS OFF-CAMPUS DRIVES 2. 2019 BATCH
3. COGNIZANT OFF-CAMPUS DRIVES 3. 2020 BATCH
4. WIPRO OFF-CAMPUS DRIVES 4. 2021 BATCH
5. CAPGEMINI OFF-CAMPUS DRIVES 5. 2022 BATCH

 

To Stay Up-to-date, Follow us on Social Media:


1.      Join our Telegram Channel:

Click Here

2.      Like us on Facebook:

Click Here

3.      Follow us on Instagram:

Click Here

4.      Follow us on LinkedIn:

Click Here

5.      Follow us on Google News:

Click Here

 

Capgemini ADAPT Sprint 1 (Bus Reservation Solutions):


Capgemini ADAPT Sprint 2 (Bus Reservation System):


Study Materials for Interview Preparation (FREE MATERIALS):


  1. 240 Core Java Questions & Answers with PDF Download Link – Click Here
  2. 230+ SQL interview questions & answers pdf download – Click Here
  3. 50 LeetCode Interview Questions with Answers – PDF Notes – Click Here