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

Assign1_Akshay #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Account_Akshay/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Account_Akshay/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AutoGenerate</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions Account_Akshay/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Binary file added Account_Akshay/bin/com/demo/bean/Account.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions Account_Akshay/src/com/demo/bean/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.demo.bean;
import java.util.Date;

public class Account {
static {
//ifsc = "AKSH";
cnt = 0;
}
//public static String ifsc
private static int cnt;
private int perId;
private String pName;
private String typeOfAcc;
private Date dOj;
private double balance;

//default constructor
public Account() {
perId = 0;
pName = null;
typeOfAcc = null;
dOj = null;

}

//parameterized constructor
public Account(String pName, String typeOfAcc, Date dOj, double bal) {
this.perId = cnt++ ;
this.pName = pName;
this.typeOfAcc = typeOfAcc;
this.dOj = dOj;
this.balance = bal;
}

//setter and getter methods
public int getId() {
return this.perId;
}

public void setId(int perId) {
this.perId = perId;
}

public void setBal (double bal) {
this.balance = bal;
}

public double getBal() {
return this.balance;
}

public String getpName() {
return this.pName;
}

public void setpName(String pName) {
this.pName = pName;
}

//function for depositing operation
public void deposit(double amt) {
balance = balance + amt;
}

//function for withdrawing operation
public void withdraw(double amt) {
if(balance-10000 >= amt) {
balance = balance - amt;
}
else {
System.out.println("Less balance");
}
}

@Override
public String toString() {
return "Id: "+perId +"\nName: " +pName + "\nType of account:"+ typeOfAcc + "\nDate of opening :"+ dOj+"\nbalance: "+balance;
}
}
101 changes: 101 additions & 0 deletions Account_Akshay/src/com/demo/service/AccountService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.demo.service;
import java.util.Scanner;
import com.demo.bean.Account;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AccountService {

//public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
public static Scanner sc = new Scanner(System.in);

// function to accept account data
public static void acceptAccountData(Account[] acc) {
for (int i = 0; i < acc.length; i++) {
/*
* System.out.println("Enter account ID"); int id = sc.nextInt();
*/
System.out.println("Enter account holder's name: ");
String name = sc.next();
System.out.println("Enter type of account: ");
String acctype = sc.next();
System.out.println("Enter balance: ");
double bal = sc.nextDouble();
//System.out.println("Enter date of opening: ");
//String dt = sc.next();
Date dOj = new Date();
acc[i] = new Account(name, acctype, dOj, bal);

}

}

// function to search by ID
public static int searchById(Account[] acc, int id) {
for (int i = 0; i < acc.length; i++) {
if (acc[i].getId() == id) {
return i;
}
}
return -1;
}

// function to deposit amount
public static int depositAmt(Account[] acc, int id, double amt) {
int pos = searchById(acc, id);
if (pos != -1) {
acc[pos].deposit(amt);
System.out.println("New balance:" + acc[pos].getBal());
return pos;
} else {
System.out.println("person not found");
return -1;
}
}

// function to withdraw amount
public static int withdrawAmt(Account[] acc, int id, double amt) {

int pos = searchById(acc, id);
if (pos != -1) {
acc[pos].withdraw(amt);
System.out.println("New balance:" + acc[pos].getBal());
return pos;
} else {
System.out.println("person not found");
return -1;
}

}

// function to display account data
public static void displayData(Account[] acc) {
for (int i = 0; i < acc.length; i++) {
if (acc[i] != null) {
System.out.println(acc[i]);
} else {
break;
}
}
}

public static int searchByName(Account[] a, String nm) {
for (int i = 0; i < a.length; i++) {
if (a[i].getpName().equals(nm)) {
return i;
}
}
return -1;
}

// display account by ID
public static void dispById(Account[] a, int id) {
int pos = searchById(a, id);
if (pos != -1) {
System.out.println(a[pos]);
} else {
System.out.println("Account does not exist");
}
}
}
70 changes: 70 additions & 0 deletions Account_Akshay/src/com/demo/test/TestAccountClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.demo.test;
import com.demo.bean.Account;
import com.demo.service.AccountService;
import java.util.Scanner;

public class TestAccountClass {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
Account[] a = new Account[3];
int choice = 0;
// Do-While Loop
do {
System.out.println("1.Add new person");
System.out.println("2.Search person by name");
System.out.println("3.Deposit amount");
System.out.println("4.Withdraw amount");
System.out.println("5.Display account by id");
System.out.println("6.Exit");
choice = sc.nextInt();

// switch case
switch (choice) {

case 1:
AccountService.acceptAccountData(a);
break;
case 2:
System.out.println("Enter the name to be searched: ");
String nm = sc.next();
int posn = AccountService.searchByName(a, nm);
if (posn != -1) {
System.out.println(a[posn]);
} else {
System.out.println("Person does not exist");
}
break;
case 3:
System.out.println("Enter the amount to be deposited: ");
double damt = sc.nextDouble();
System.out.println("Enter the person ID: ");
int dId = sc.nextInt();
AccountService.depositAmt(a, dId, damt);
break;
case 4:
System.out.println("Enter the amount to be withdrawn: ");
double wAmt = sc.nextDouble();
System.out.println("Enter the person ID: ");
int wId = sc.nextInt();
AccountService.withdrawAmt(a, wId, wAmt);
break;
case 5:
System.out.println("Enter Id to display data: ");
int id = sc.nextInt();
int pos = AccountService.searchById(a, id);
if (pos != -1) {
System.out.println(a[pos]);
} else {
System.out.println("Person does not exist: ");
}
break;
case 6:
System.exit(0);
}
} while (choice != 6);
sc.close();
}

}
6 changes: 6 additions & 0 deletions Practical_Exam_Akshay_Ramdev_WPS4/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Practical_Exam_Akshay_Ramdev_WPS4/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PracticalExam</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
64 changes: 64 additions & 0 deletions Practical_Exam_Akshay_Ramdev_WPS4/src/com/demo/bean/Apparel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//Shubham Ramesh Tapele
//Apparel Class which extends Item Class and Stores Apparel Specific Variables

package com.demo.bean;

public class Apparel extends Item{
private String size;
private String material;
private int qnty;

//default constructor
public Apparel() {
super();
}

//parameterised Constructor
public Apparel(String size, String material, int qnty, int itemCode, String itemName, double price) {
super();
this.size = size;
this.material = material;
this.qnty = qnty;
}

//Getter and Setter Methods
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getMaterial() {
return material;
}
public void setMaterial(String material) {
this.material = material;
}
public int getQnty() {
return qnty;
}
public void setQnty(int qnty) {
this.qnty = qnty;
}


@Override
public String toString() {
return "Apparel [size=" + size + ", material=" + material + ", qnty=" + qnty + "]";
}
//compare function to sort by qnty
public int compareTo(Apparel ob) {
System.out.println("In person compareTo"+qnty+"----"+ob.qnty);
if(this.qnty>ob.qnty) {
return -1;
}else if(this.qnty==ob.qnty) {
return 0;
}
else {
return 1;
}
}



}
Loading