Question

In: Computer Science

Part I – Build a Customer Business Object. This class will have 6 properties, custId, custPassword,...

Part I – Build a Customer Business Object. This class will have 6 properties, custId, custPassword, custFirstName, custLastName, custAddress and custEmail. Build an empty args Constructor in the Customer class that initializes all properties to 0 or “”. Also build a constructor that takes all 6 args and set the appropriate properties. Then build the following 3 methods:

  1.   selectDB(custID);   //to find a customer’s info in the DB

            To Test the selectDB() method use this code in the main():

                             Customer c1 = new Customer();

                   c1.selectDB(custId);

                   c1.display();

  1.   insertDB(custId, custPassword, custFirstName, custLastName, custAddress, custEmail) // to insert a new Customer in the DB
  2.   deleteDB();   //this method will delete the Customer from the DB

//so to check login execute the following code à

          Customer c1 = new Customer();   //creates empty object

c1.selectDB(id);   //does the DB lookup to find Customer

String pwdb = c1.getPassword();

          if (pwgui.equals(pwdb)) { //this compares pw(from gui to the

      //password from the database

                              //login correct

          }       

          else {

                             //login incorrect

          }

Part II – Now build an Account Business Object. This class will have 4 properties, acctNo, custId, type and balance. Build an empty args Constructor in the Customer class that initializes all properties to 0 or “”. Also build a constructor that takes all 4 args and set the appropriate properties. Then build the following 3 methods:

  1.   selectDB(acctNo);   //to find a account’s info in the DB
  2.   insertDB(aNo, cid, ty, bal) // to insert a new Account into the DB
  3.   deleteDB();   //this method will delete the current Cust from the DB

            To Test the selectDB() method use this code in the main():

                   Account a1 = new Account();

                   a1.selectDB(acctNo);

                   a1.display();

Solutions

Expert Solution

CustomerBusiness.java

package com.bank;

import java.util.List;

public class CustomerBusiness {

private int CustId;

private String CustPassword;

private String CustFirstName;

private String CustLastName;

private String CustAddress;

private String CustEmail;

public int getCustId() {

return CustId;

}

public void setCustId(int custId) {

CustId = custId;

}

public String getCustPassword() {

return CustPassword;

}

public void setCustPassword(String custPassword) {

CustPassword = custPassword;

}

public String getCustFirstName() {

return CustFirstName;

}

public void setCustFirstName(String custFirstName) {

CustFirstName = custFirstName;

}

public String getCustLastName() {

return CustLastName;

}

public void setCustLastName(String custLastName) {

CustLastName = custLastName;

}

public String getCustAddress() {

return CustAddress;

}

public void setCustAddress(String custAddress) {

CustAddress = custAddress;

}

public String getCustEmail() {

return CustEmail;

}

public void setCustEmail(String custEmail) {

CustEmail = custEmail;

}

public CustomerBusiness(int custId, String custPassword, String custFirstName, String custLastName,

String custAddress, String custEmail) {

super();

CustId = custId;

CustPassword = custPassword;

CustFirstName = custFirstName;

CustLastName = custLastName;

CustAddress = custAddress;

CustEmail = custEmail;

}

public CustomerBusiness(){

super();

CustId = 0;

CustPassword = "";

CustFirstName = "";

CustLastName = "";

CustAddress = "";

CustEmail = "";

}

public void insertDb(int custId, String custPassword, String custFirstName, String custLastName,

String custAddress, String custEmail){

}

public String deleteDb(int custId){

return null;

}

public List<CustomerBusiness> selectDb(int custId){

return null;

}

}

AccountBusiness.java

package com.bank;

public class AccountBusiness {

public String deposit(double amt){

return null;

}

public String withdraw(double amt){

return null;

}

public double getBalance(int acctid){

return 0;

}

}

Customer.java

package com.bank;

import java.util.List;

public class Customer {

CustomerBusiness c1 = new CustomerBusiness();

AccountList alist;

public boolean validatePassword(int custid,String passwordUser){

List<CustomerBusiness> mylist= c1.selectDb(101);

if(!mylist.isEmpty()){

String password = mylist.get(0).getCustPassword();

if(password.equals(passwordUser)){

//valid log in

return true;

}else{

return false;

//invalid login

}

}

return false;

}

}

Account.java

package com.bank;

import java.util.List;

public class Account {

private int acctId;

private double Balance;

private int custId;

public int getAcctId() {

return acctId;

}

public void setAcctId(int acctId) {

this.acctId = acctId;

}

public double getBalance() {

return Balance;

}

public void setBalance(double balance) {

Balance = balance;

}

public int getCustId() {

return custId;

}

public void setCustId(int custId) {

this.custId = custId;

}

AccountBusiness ab = new AccountBusiness();

public List<Account> selectDb(int acctid){

ab.deposit(100.00);

return null;

}

public void Display(){

System.out.println("display all balances");

}

}

AccountList.java

package com.bank;

public class AccountList {

public void addAcount(Account a1){

}

public void display(int custid){

System.out.println("arraylist to display all");

}

}

Loginpage.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<form name="custForm" action="/Login">
CutomerId:<input type="text" name="custid" /><br/>
password:<input type="password" name="password" /><br/>
<input type="submit" name="submit"/>
</form>

</body>
</html>

LoginServlet.java

package com.bank;

import java.io.IOException;

import javax.servlet.Servlet;

import javax.servlet.ServletConfig;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServlet;

public class LoginServlet implements Servlet{

@Override

public void destroy() {

}

@Override

public ServletConfig getServletConfig() {

return null;

}

@Override

public String getServletInfo() {

return null;

}

@Override

public void init(ServletConfig arg0) throws ServletException {

}

@Override

public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {

int custid = Integer.parseInt(request.getParameter("custid"));

String password = request.getParameter("password");

Customer c1=new Customer();

if(c1.validatePassword(custid,password)){

}else{

}

}

}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>BankAccounts</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
  
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.bank.LoginServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
</web-app>


Related Solutions

C#. Build a class that will be called “MyDate”. The class should have 3 properties: month,...
C#. Build a class that will be called “MyDate”. The class should have 3 properties: month, day and year. Make month, day and year integers. Write the get and set functions, a display function, and constructors, probably two constructors. (No Database access here.)
Part I: Have a program class named TestArrays This class should have a main() method that...
Part I: Have a program class named TestArrays This class should have a main() method that behaves as follows: Have an integer array of size 10. Using a loop, fill the elements with increments of 5, starting with 5 in the first element. Using the array elements, sum the second, fifth and seventh elements. Display the sum with a label. Change the fourth element to 86. Subtract 9 from the ninth element. Using a loop, display the elements of the...
Design and build objects to be used by a real estate company for listing the properties for sale. A base object of a property is necessary.
IN JAVA OOPDesign and build objects to be used by a real estate company for listing the properties for sale. A base object of a property is necessary. Decide what common about all properties and include these in the property object. Different type of properties are land, commercial and residential. A residential property can be single family and multi family. A commercial can be a commercial can be either a farm or non-farm.Look at real estate websites and decide what...
I have to create a program that: define class cust(I already did this part) create an...
I have to create a program that: define class cust(I already did this part) create an array of cust (size 10)to hold the data of the class. (done) read the date from a file(everything from the class - already done) call a function print cust(this function will print all the data in table format)....first, last, state, sales history(0,1,2), units Read the data from a file (you may break up the strings and numeric values any way you choose (separate lines...
Monkey Business, an import business, builds special-order yachts. They decide to build one for a customer...
Monkey Business, an import business, builds special-order yachts. They decide to build one for a customer for at a cost $2,500,000. It will take 2 years (they start building in June 1, 2007) to build with total costs of $1,900,000: costs of $320,000 in 2007; $1,200,000 in 2008; and the remainder in 2009 (assume they stick to budget). The customer puts a deposit down of $500,000 and pays the remainder in 4 installments, each due every 6 months. For each...
i have a skeleton class and i have to fill some methods of this class. i...
i have a skeleton class and i have to fill some methods of this class. i am having difficulties especially with the findAppointment method. so this is the problem. Implement a superclass Appointment and subclasses OneTime, Daily, and Monthly. An Appointment has a description (for example “see the dentist”) and a date. Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether...
Discuss specific examples of world-class technology business that you have seen as a customer. What forces...
Discuss specific examples of world-class technology business that you have seen as a customer. What forces led to the commercialization of the science behind one or more of these companies products. why and how do some companies inspire world-class service, while others fail?
I have code for an AVL tree. I Have have a node class and tree class....
I have code for an AVL tree. I Have have a node class and tree class. I need a  node object that refrences the root(top) of the tree. my current code throws NullPointerException when I try to access the root properties. here is the important snippets of my code, it is in java. public class Node { private Node left=null,right=null; public int height=1; private String Item; private int balance=0; Node(String item) { this.Item=item; } } -------------------------------------------------- public class AVLTree { public...
Part I An object is through from the origin at an initial velocity of v0 and...
Part I An object is through from the origin at an initial velocity of v0 and at an angle θ in relation to the horizon. a. write out r->(t) for the object b. find the velocity vector and acceleration vector for the object. c. calculate the angle between the velocity vector and the acceleration vector at any point in time t. Part II An object is moving upwards on a slope at initial velocity v0. There is friction between the...
I JUST NEED AN ANSWER FOR 4,5, AND 6... THANKS! Trial Object Distance (cm) Object Size...
I JUST NEED AN ANSWER FOR 4,5, AND 6... THANKS! Trial Object Distance (cm) Object Size (cm) Image Distance (cm) Image Size/Orientation (cm) Focal Length (cm) 1 11.25 2.00 87.75 15.5 / inverted 2 87.60 2.00 11.40 0.300 / inverted 3 23.35 XXX 17.65 XXX 4 17.55 XXX 23.45 XXX XXX XXX XXX XXX Average XXX XXX XXX XXX Std. Dev. (5 points x 6 = 30 points) 1. Plot the 1/o vs. 1/i graph from all data collected. (10...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT