Professional Documents
Culture Documents
Case Study Sprint 4 All Solutions With 100 Points
Case Study Sprint 4 All Solutions With 100 Points
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
class Admin{
Admin(){}
this.email=email;
this.password=password;
this.name=name;
// Getter1
return email;
// Setter1
this.email = email;
}
// Getter2
// Setter2
this.password = password;
// Getter3
return name;
// Setter3
this.name = name;
class Toy{
public Toy(){}
int refundableDeposit){
this.toyId=toyId;
this.toyName=toyName;
this.toyType=toyType;
this.minAge=minAge;
this.maxAge=maxAge;
this.price=price;
this.quantity=quantity;
this.rentalAmount=rentalAmount;
this.refundableDeposit=refundableDeposit;
}
// Getter1
return toyId;
// Setter1
this.toyId = toyId;
// Getter2
return toyName;
// Setter2
this.toyName = toyName;
// Getter3
return toyType;
}
// Setter3
this.toyType = toyType;
// Getter4
return minAge;
// Setter4
this.minAge = minAge;
// Getter5
return maxAge;
// Setter5
this.maxAge = maxAge;
}
// Getter6
return price;
// Setter6
this.price = price;
// Getter7
return quantity;
// Setter7
this.quantity=quantity;
// Getter8
return rentalAmount;
}
// Setter8
this.rentalAmount = rentalAmount;
// Getter9
return refundableDeposit;
// Setter9
this.refundableDeposit = refundableDeposit;
int i1=Integer.parseInt(str1);
toy.setToyId(i1);
toy.setToyName(str2);
toy.setToyType(str3);
int i4=Integer.parseInt(str4);
toy.setMinAge(i4);
int i5=Integer.parseInt(str4);
toy.setMaxAge(i5);
String str6 = in.nextLine();
int i6=Integer.parseInt(str6);
toy.setPrice(i6);
int i7=Integer.parseInt(str7);
toy.setQuantity(i7);
int i8=Integer.parseInt(str8);
toy.setRentalAmount(i8);
int i9=Integer.parseInt(str9);
toy.setRefundableDeposit(i9);
3.toy exception
import java.util.*;
public InvalidAgeException() {
//super(message);
}
class Toy {
private int id;
private String name;
private int minAge;
private int maxAge;
public Toy() {
}
public Toy(int id, String name, int minAge, int maxAge) throws InvalidAgeException {
if (minAge < 0 || minAge>12 || maxAge > 12 || maxAge<0) {
throw new InvalidAgeException();
} else {
this.id = id;
this.name = name;
this.minAge = minAge;
this.maxAge = maxAge;
}
}
return minAge;
}
Source() {
toys[0][0] = "1";
toys[0][1] = "Stickle Bricks";
toys[1][0] = "2";
toys[1][1] = "Robot Dog";
toys[2][0] = "3";
toys[2][1] = "Magic 8 Ball";
toys[3][0] = "4";
toys[3][1] = "Juggling Clubs";
toys[4][0] = "5";
toys[4][1] = "Chutes and Ladders";
}
public static void main(String[] args) throws InvalidAgeException {
Scanner scanner = new Scanner(System.in);
int id = scanner.nextInt();scanner.nextLine();
try {
Toy toy = new Toy(id, name, minAge, maxAge);
System.out.println(toy.getToyName());
}
catch (InvalidAgeException e) {
System.out.println("InvalidAgeException");
}
}
}
4.customer exception
import java.util.*;
/**
*/
super(message);
}
}
class Toy {
public Toy() {
public Toy(int id, String name, int minAge, int maxAge) throws InvalidAgeException {
} else {
this.id = id;
this.name = name;
this.minAge = minAge;
this.maxAge = maxAge;
return id;
}
this.id = id;
return minAge;
if (minAge < 0)
this.minAge = minAge;
return maxAge;
this.maxAge = maxAge;
}
return name;
this.name = name;
return name;
this.name = name;
Source() {
toys[0][0] = "1";
toys[0][1] = "Stickle Bricks";
toys[1][0] = "2";
toys[2][0] = "3";
toys[3][0] = "4";
toys[4][0] = "5";
int id = Integer.parseInt(scanner.nextLine());
try {
System.out.println(toy.getToyName());
} catch (InvalidAgeException e) {
System.out.println(e.getMessage());
5.admin service
import java.util.*;
interface AdminService {
Toy[] getToys();
@Override
toyArray[count] = toy;
count++;
if (toyArray[i].getToyId() == toy.getToyId()) {
toyArray[i] = toy;
break;
if (toyArray[i].getToyId() == toy.getToyId()) {
toyArray[i] = null;
break;
return toyArray;
}
}
class Toy {
Toy(int id, String name, String type, int min, int max, double price, int quant, double rent, double
refund) {
this.toyId = id;
this.toyName = name;
this.toyType = type;
this.minAge = min;
this.maxAge = max;
this.price = price;
this.quantity = quant;
this.rentalAmount = rent;
this.refundableDeposit = refund;
return toyId;
this.toyId = toyId;
}
return minAge;
this.minAge = minAge;
return maxAge;
this.maxAge = maxAge;
return quantity;
this.quantity = quantity;
}
public String getToyName() {
return toyName;
this.toyName = toyName;
return toyType;
this.toyType = toyType;
return price;
this.price = price;
}
public double getRentalAmount() {
return rentalAmount;
this.rentalAmount = rentalAmount;
return refundableDeposit;
this.refundableDeposit = refundableDeposit;
return ("Toy Name: " + this.toyName + "\nToy Type: " + this.toyType + "\nQuantity: " + this.quantity
class Source {
Toy[] toys;
switch (choice) {
case 1:
if (s.hasNext()) {
id = s.nextInt();
name = s.next();
type = s.next();
min = s.nextInt();
max = s.nextInt();
price = s.nextDouble();
quantity = s.nextInt();
rent = s.nextDouble();
refund = s.nextDouble();
Toy t = new Toy(id, name, type, min, max, price, quantity, rent, refund);
adm.addToy(t);
toys = adm.getToys();
System.out.println(adm.toString());
}
break;
case 2:
id = s.nextInt();
name = s.next();
type = s.next();
min = s.nextInt();
max = s.nextInt();
price = s.nextDouble();
quantity = s.nextInt();
rent = s.nextDouble();
refund = s.nextDouble();
Toy t1 = new Toy(id, name, type, min, max, price, quantity, rent, refund);
adm1.updateToy(t1);
System.out.println(adm1.toString());
break;
case 3:
id = s.nextInt();
name = s.next();
type = s.next();
min = s.nextInt();
max = s.nextInt();
price = s.nextDouble();
quantity = s.nextInt();
rent = s.nextDouble();
refund = s.nextDouble();
Toy t2 = new Toy(id, name, type, min, max, price, quantity, rent, refund);
adm2.deleteToy(t2);
break;
case 4:
toys = adm3.getToys();
System.out.println(adm3.toString());
s.close();
import java.util.Scanner;
interface AdminService{
interface CustomerService{
boolean validateCustomer(String email, String password);
class Customer
// public Customer(){
// }
public Customer(int customerId, String customerName, String email, String password, String address) {
// super();
this.customerId = customerId;
this.customerName = customerName;
this.password = password;
this.address = address;
this.email = email;
return password;
return email;
}
class Admin
// public Admin()
// {
// }
// super();
this.password = password;
this.name = name;
this.email = email;
return password;
AdminServiceImpl()
adminArray[0]=new Admin("Krithick","krithick@gmail.com","krithi");
adminArray[1]=new Admin("Rajan","rajan@gmail.com","rajan#345");
adminArray[2]=new Admin("Chandrav","chand@gmail.com","wel$234");
adminArray[3]=new Admin("Ankit","ankit@gmail.com","kit@56");
adminArray[4]=new Admin("Akilan","akilan@gmail.com","ak*76");
for(Admin a:adminArray){
return true;
return false;
}
public CustomerServiceImpl()
for(Customer c:customerArray){
return true;
return false;
}
int n = sc.nextInt();
if(n==1){
if(flag)
System.out.println("1.Rent Toys");
else if(n==2){
if(flag)
{
7.customer service
import java.util.Scanner;
interface CustomerService
void display();
class Toy{
int toyId;
String toyName;
String toyType;
int minAge;
int maxAge;
double price;
int rentalAmt;
int refundableDeposit;
int quantity;
public Toy(int toyId, String toyName, String toyType, int minAge, int maxAge, double price, int
refundableDeposit,int quantity, int rentalAmt){
this.toyId=toyId;
this.toyName=toyName;
this.toyType=toyType;
this.minAge=minAge;
this.maxAge=maxAge;
this.price=price;
this.rentalAmt=rentalAmt;
this.refundableDeposit=refundableDeposit;
this.quantity=quantity;
return toyId;
return toyName;
return toyType;
return quantity;
return rentalAmt;
}
CustomerServiceImpl()
availableToys[1]=new Toy(130,"Car","Toy",1,5,100,30,20,100);
availableToys[2]=new Toy(150,"Kite","Toy",3,8,100,50,20,100);
availableToys[3]=new Toy(180,"Airplane","Toy",4,7,500,30,50,20);
for(int i=0;i<4;i++){
if(availableToys[i].getToyId()==toyId){
System.out.println("Quantity: "+availableToys[i].getQuantity());
System.out.print("RentalAmount: "+availableToys[i].getRentalAmount());
break;
{
}
int toyId=sc.nextInt();
cs.rent(toyId);
import java.util.Scanner;
interface AdminService {
interface CustomerService {
}
class Customer {
public Customer() {
public Customer(int customerId, String customerName, String email, String password, String address) {
super();
this.customerId = customerId;
this.customerName = customerName;
this.email = email;
this.password = password;
this.address = address;
return this.customerId;
class Toy {
public Toy() {
public Toy(int toyId, String toyName, String toyType, int minAge, int maxAge, double price, int
rentalAmt,
int refundableDeposit, int quantity) {
this.toyId = toyId;
this.toyName = toyName;
this.toyType = toyType;
this.minAge = minAge;
this.maxAge = maxAge;
this.price = price;
this.rentalAmt = rentalAmt;
this.refundableDeposit = refundableDeposit;
this.quantity = quantity;
return this.toyId;
return this.toyName;
}
class CustomerServiceImpl extends Customer implements CustomerService {
public CustomerServiceImpl() {
if (customerArray[i].getCustomerId() == id) {
return customerArray[i];
return null;
AdminServiceImpl() {
availableToys[0] = new Toy(120, "Rubber Ducky", "Toy", 1, 3, 200, 20, 20, 200);
if (availableToys[i].getToyId() == id) {
return availableToys[i];
return null;
//int ch=sc.nextInt();
//int id=sc.nextInt();
//sc.close();
//switch(ch) {
// Customer customer=customerService.searchCustomer(id);
// System.out.println(customerService.toString());
// break;
// Toy toy=adminService.searchToy(id);
// System.out.println(toy.toString());
// break;
//default
: System.out.println("Invalid Choice");
//}
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
interface AdminService{
class Toy{
this.toyId=toyId;
this.toyName=toyName;
this.toyType=toyType;
this.minAge=minAge;
this.maxAge=maxAge;
this.price=price;
this.quantity=quantity;
this.rentalAmount=rentalAmount;
this.refundableDeposit=refundableDeposit;
return toyId;
}
public void setToyId(int toyId){
this.toyId=toyId;
return toyName;
return toyType;
return minAge;
return maxAge;
return price;
return quantity;
return rentalAmount;
return refundableDeposit;
this.toyName=toyName;
}
this.toyType=toyType;
this.minAge=minAge;
this.maxAge=maxAge;
this.price=price;
this.quantity=quantity;
this.rentalAmount=rentalAmount;
this.refundableDeposit=refundableDeposit;
}
class ElectronicToy extends Toy{
super(toyId,toyName,toyType,minAge,maxAge,price,quantity,rentalAmount,refundableDeposit);
this.numberOfBatteries=numberOfBatteries;
this.operatingMode=operatingMode;
"\nType: "+super.getToyType()+
"\nMode: "+operatingMode+
"\nBatteries: "+numberOfBatteries;
super(toyId,toyName,toyType,minAge,maxAge,price,quantity,rentalAmount,refundableDeposit);
this.noOfSpeakers=noOfSpeakers;
Source()
toys[0][0]="1";
toys[0][1]="Stickle Bricks";
toys[1][0]="2";
toys[1][1]="Robot Dog";
toys[2][0]="3";
toys[2][1]="Magic 8 Ball";
toys[3][0]="4";
toys[3][1]="Juggling Clubs";
toys[4][0]="5";
}*/
int n=sc.nextInt();
if(n==1){
String toyName=sc.nextLine();
String toyType=sc.nextLine();
sc.next();
int minAge=sc.nextInt();
int maxAge=sc.nextInt();
double price=sc.nextDouble();
int quantity=sc.nextInt();
double rentalAmount=sc.nextDouble();
double refundableDeposit=sc.nextDouble();
int numberOfBatteries=sc.nextInt();
String operatingMode=sc.next();
ElectronicToy e=new
ElectronicToy(1,toyName,toyType,minAge,maxAge,price,quantity,rentalAmount,refundableDeposit,num
berOfBatteries,operatingMode);
System.out.println(e.toString());
}else if(n==2){
String toyName=sc.next();
String toyType=sc.nextLine();
int minAge=sc.nextInt();
int maxAge=sc.nextInt();
double price=sc.nextDouble();
int quantity=sc.nextInt();
double rentalAmount=sc.nextDouble();
double refundableDeposit=sc.nextDouble();
int noOfSpeakers=sc.nextInt();
MusicalToy m=new
MusicalToy(1,toyName,toyType,minAge,maxAge,price,quantity,rentalAmount,refundableDeposit,noOfS
peakers);
System.out.println(m.toString());
}