diff --git a/BankAccountUML.png b/BankAccountUML.png new file mode 100644 index 0000000..3f2043b Binary files /dev/null and b/BankAccountUML.png differ diff --git a/Product Inventory Project UML.png b/Product Inventory Project UML.png new file mode 100644 index 0000000..30a1d2b Binary files /dev/null and b/Product Inventory Project UML.png differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b5c240d --- /dev/null +++ b/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + battin.preston + AccessControl + 1.0-SNAPSHOT + + + + junit + junit + 4.12 + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + + + + + + + \ No newline at end of file diff --git a/src/main/java/Account.java b/src/main/java/Account.java new file mode 100644 index 0000000..1923e40 --- /dev/null +++ b/src/main/java/Account.java @@ -0,0 +1,30 @@ +/** + * Created by prestonbattin on 1/18/17. + */ +public abstract class Account { + + protected String accountName; + protected double balance; + + + Account(String accountName, double balance){ + + this.accountName = accountName; + this.balance = balance; + } + + protected abstract void creditAccount(double amount); + protected abstract void debitAccount(double amount); + + protected String getAccountName(){ + + return this.accountName; + } + + protected double getBalance(){ + + return this.balance; + } + + +} diff --git a/src/main/java/BusinessAccount.java b/src/main/java/BusinessAccount.java new file mode 100644 index 0000000..08bfcfc --- /dev/null +++ b/src/main/java/BusinessAccount.java @@ -0,0 +1,52 @@ +/** + * Created by prestonbattin on 1/19/17. + */ +public class BusinessAccount extends Account{ + + static private int accountCount = 1; + private int businessAccountNumber; + private double interest = 2.5; + + BusinessAccount(String name, double balance){ + + super(name, balance); + + this.businessAccountNumber = accountCount; + accountCount++; + + this.interest = interest; + } + + @Override + protected void creditAccount(double amount) { + this.balance += amount; + } + + @Override + protected void debitAccount(double amount) { + + this.balance -= amount; + } + + @Override + public double getBalance(){ + + return super.getBalance(); + } + + public int getBusinessAccountNumber(){ + + return this.businessAccountNumber; + } + + @Override + public String getAccountName(){ + + return super.getAccountName(); + } + + public double getInterest(){ + + return this.interest; + } +} diff --git a/src/main/java/CheckingAccount.java b/src/main/java/CheckingAccount.java new file mode 100644 index 0000000..db8c20b --- /dev/null +++ b/src/main/java/CheckingAccount.java @@ -0,0 +1,47 @@ +/** + * Created by prestonbattin on 1/19/17. + */ +public class CheckingAccount extends Account { + + static private int accountCount = 1; + private int checkingAccountNumber; + + + CheckingAccount(String accountName, double balance){ + super(accountName,balance); + + this.checkingAccountNumber = accountCount; + accountCount++; + } + + @Override + protected void creditAccount(double amount) { + + this.balance += amount; + } + + @Override + protected void debitAccount(double amount) { + + this.balance -= amount; + } + + @Override + public double getBalance(){ + + return super.getBalance(); + } + + public int getCheckingAccountNumber(){ + + return this.checkingAccountNumber; + } + + @Override + public String getAccountName(){ + + return super.getAccountName(); + } + + +} diff --git a/src/main/java/Human.java b/src/main/java/Human.java new file mode 100644 index 0000000..37b2ae0 --- /dev/null +++ b/src/main/java/Human.java @@ -0,0 +1,44 @@ +/** + * Created by prestonbattin on 1/18/17. + */ +public class Human { + + protected String name, gender, occupation, address; + protected int age; + + + Human(String name, String gender, String occupation, String address, int age){ + + this.name = name; + this.gender = gender; + this.occupation = occupation; + this.address = address; + this.age = age; + } + + protected void getName(){ + + System.out.println("Your name is " + name); + } + + protected void getGender(){ + + System.out.println("You are " + gender); + } + + protected void getOccupation(){ + + System.out.println("Your occupation is " + occupation); + } + + protected void getAddress(){ + + System.out.println("Your address is " + address); + } + + protected void getAge(){ + + System.out.println("Your age is " + age); + } +} + diff --git a/src/main/java/Inventory.java b/src/main/java/Inventory.java new file mode 100644 index 0000000..b80f58f --- /dev/null +++ b/src/main/java/Inventory.java @@ -0,0 +1,31 @@ +/** + * Created by prestonbattin on 1/18/17. + */ +public class Inventory { + + int quantity; + double totalCost, price; + + + Inventory(int quantity, double price){ + + this.quantity = quantity; + this.price = price; + } + + public double getTotalPrice(){ + + return quantity * price; + } + + public int getQuantity(){ + + return this.quantity; + } + + public double getPrice(){ + + return this.price; + } + +} diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000..f998bad --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,57 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Created by prestonbattin on 1/18/17. + */ +public class Main { + + public static void main(String[] args) { + + //Rotate Array + + List number = new ArrayList(); + + for (int i = 1; i < 7; i++) { + number.add(i); + } + System.out.println("Before rotations " + Arrays.toString(number.toArray())); + RotateArray rotate = new RotateArray(); + System.out.println("after rotation"); + rotate.swapList(number, 5); + + + //Human Class + + Human person = new Human("Kent Klark", "Male", "Bus Boy", "101 Wazoo Lane", 23); + SuperHero superHero = new SuperHero("Kevin", "Female", "Cheer Leader", "454 Hello World Lane", 20, "Good", + "Kelly Frost", "Laser Vision"); + + person.getName(); + person.getGender(); + person.getOccupation(); + person.getAddress(); + person.getAge(); + + superHero.getName(); + superHero.getGender(); + superHero.getOccupation(); + superHero.getAddress(); + superHero.getAge(); + superHero.getSide(); + superHero.getHeroName(); + superHero.getAbility(); + + //Class Manager + + + + + + + + + } +} + diff --git a/src/main/java/Product.java b/src/main/java/Product.java new file mode 100644 index 0000000..cd3a7ec --- /dev/null +++ b/src/main/java/Product.java @@ -0,0 +1,40 @@ +/** + * Created by prestonbattin on 1/18/17. + */ +public class Product { + protected Inventory tracker; + protected double price; + protected int id, quantity; + + Product(int id, int quantity, double price){ + + this.price = price; + this.id = id; + this.quantity = quantity; + + tracker = new Inventory(quantity, price){}; + } + + + public int getId(){ + + return this.id; + } + + public double getPrice(){ + + return tracker.getPrice(); + } + + public int getQuantity(){ + + return tracker.quantity; + } + + public double getTotalCost(){ + + return tracker.getTotalPrice(); + } + + +} diff --git a/src/main/java/RotateArray.java b/src/main/java/RotateArray.java new file mode 100644 index 0000000..c2a1102 --- /dev/null +++ b/src/main/java/RotateArray.java @@ -0,0 +1,22 @@ + +import java.util.*; + + + +/** + * Created by prestonbattin on 1/18/17. + */ +public class RotateArray { + + + + public void swapList(List array, int rotate){ + + + + Collections.rotate(array, rotate); + + System.out.println(Arrays.toString(array.toArray())); + + } +} diff --git a/src/main/java/SavingsAccount.java b/src/main/java/SavingsAccount.java new file mode 100644 index 0000000..d7a78f1 --- /dev/null +++ b/src/main/java/SavingsAccount.java @@ -0,0 +1,53 @@ +/** + * Created by prestonbattin on 1/19/17. + */ +public class SavingsAccount extends Account { + + static private int accountCount = 1; + private int savingsAccountNumber; + private double interest = 1.5; + + + SavingsAccount(String name, double balance){ + + super(name, balance); + + this.savingsAccountNumber = accountCount; + accountCount++; + } + + @Override + protected void creditAccount(double amount) { + + this.balance += amount; + this.interest = interest; + } + + @Override + protected void debitAccount(double amount) { + + this.balance -= amount; + } + + @Override + public double getBalance(){ + + return super.getBalance(); + } + + public int getSavingsAccountNumber(){ + + return this.savingsAccountNumber; + } + + @Override + public String getAccountName(){ + + return super.getAccountName(); + } + + public double getInterest(){ + + return this.interest; + } +} diff --git a/src/main/java/SuperHero.java b/src/main/java/SuperHero.java new file mode 100644 index 0000000..68f7ed9 --- /dev/null +++ b/src/main/java/SuperHero.java @@ -0,0 +1,31 @@ +/** + * Created by prestonbattin on 1/18/17. + */ +public class SuperHero extends Human { + + public String side, heroName, superAbility; + + SuperHero(String name, String gender, String occupation, String address, int age, String side, String heroName, String superAbility){ + super(name, gender, occupation, address, age ); + this.side = side; + this.heroName = heroName; + this.superAbility = superAbility; + } + + public void getSide(){ + + System.out.println("You are " + side); + + } + + public void getHeroName(){ + + System.out.println("Your Hero name is " + heroName); + } + + public void getAbility(){ + + System.out.println("Your super ability is " + superAbility); + } + +} diff --git a/src/test/java/ManagerTest.java b/src/test/java/ManagerTest.java new file mode 100644 index 0000000..ced9a60 --- /dev/null +++ b/src/test/java/ManagerTest.java @@ -0,0 +1,34 @@ +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by prestonbattin on 1/18/17. + */ +public class ManagerTest { + + @Test + public void testInitilization(){ + + Product test = new Product(001, 500, 34.6); + int expectedid = 1; + int actual = test.getId(); + Assert.assertEquals("testing id number", expectedid,actual); + int expectedQuantity = 500; + int actualQuantity = test.getQuantity(); + Assert.assertEquals("Testing Quantity", expectedQuantity, actualQuantity); + double expectedPrice = 34.6; + double actualPrice = test.getPrice(); + Assert.assertEquals("Testing price", expectedPrice,actualPrice,0); + + } + + @Test + public void testTotalCost(){ + Product test = new Product(1,200,55.5); + double expectedTotalCost = 11100; + double actualTotaCost = test.getTotalCost(); + Assert.assertEquals("Testing total cost", expectedTotalCost,actualTotaCost,0); + } + + +} diff --git a/src/test/java/TestBankAccount.java b/src/test/java/TestBankAccount.java new file mode 100644 index 0000000..32e77e4 --- /dev/null +++ b/src/test/java/TestBankAccount.java @@ -0,0 +1,105 @@ +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by prestonbattin on 1/19/17. + */ +public class TestBankAccount { + + @Test + public void TestCheckingAccountCreation(){ + + CheckingAccount test = new CheckingAccount("bob", 4500); + CheckingAccount test1 = new CheckingAccount("Sally Sue", 3500); + + String expectedName = "Sally Sue"; + String actualName = test1.getAccountName(); + Assert.assertEquals("Testing the name", expectedName,actualName); + + double expectedStartBalance = 3500; + double actualStartBalance = test1.getBalance(); + Assert.assertEquals("Testing start balance", expectedStartBalance,actualStartBalance,0); + + int expectedAccountNumber = 2; + int actualAccountNumber = test1.getCheckingAccountNumber(); + Assert.assertEquals("Checking the account number", expectedAccountNumber,actualAccountNumber); + + test1.creditAccount(500); + double expectedCreditBalance = 4000; + double actualCreditBalance = test1.getBalance(); + Assert.assertEquals("Testing credit", expectedCreditBalance,actualCreditBalance,0); + + test1.debitAccount(1000); + double expectedDebitBalance = 3000; + double actualDebitBalance = test1.getBalance(); + Assert.assertEquals("Testing debit", expectedDebitBalance,actualDebitBalance,0); + + } + + @Test + public void TestingSavingsAccountCreation(){ + + SavingsAccount test = new SavingsAccount("Kevin", 10000); + SavingsAccount test1 = new SavingsAccount("Will",4500); + + String expecteName = "Kevin"; + String actualName = test.getAccountName(); + Assert.assertEquals("Testing name", expecteName,actualName); + + double expectedStartBalance = 10000; + double actualStartBalance = test.getBalance(); + Assert.assertEquals("Testing start balance", expectedStartBalance,actualStartBalance,0); + + int expectedAccountNumber = 2; + int actualAccountNumber = test1.getSavingsAccountNumber(); + Assert.assertEquals("Checking the account number", expectedAccountNumber,actualAccountNumber); + + test.creditAccount(500); + double expectedCreditBalance = 10500; + double actualCreditBalance = test.getBalance(); + Assert.assertEquals("Testing credit", expectedCreditBalance,actualCreditBalance,0); + + test.debitAccount(1000); + double expectedDebitBalance = 9500; + double actualDebitBalance = test.getBalance(); + Assert.assertEquals("Testing debit", expectedDebitBalance,actualDebitBalance,0); + + double expectedInterest = 1.5; + double actualInterest = test.getInterest(); + Assert.assertEquals("Testing Interest", expectedInterest,actualInterest,0); + } + + @Test + public void TestingBuisnessAccount(){ + + BusinessAccount test = new BusinessAccount("Kevin", 100000); + BusinessAccount test1 = new BusinessAccount("Will",4500); + + + String expecteName = "Kevin"; + String actualName = test.getAccountName(); + Assert.assertEquals("Testing name", expecteName,actualName); + + double expectedStartBalance = 100000; + double actualStartBalance = test.getBalance(); + Assert.assertEquals("Testing start balance", expectedStartBalance,actualStartBalance,0); + + int expectedAccountNumber = 2; + int actualAccountNumber = test1.getBusinessAccountNumber(); + Assert.assertEquals("Checking the account number", expectedAccountNumber,actualAccountNumber); + + test.creditAccount(1000); + double expectedCreditBalance = 101000; + double actualCreditBalance = test.getBalance(); + Assert.assertEquals("Testing credit", expectedCreditBalance,actualCreditBalance,0); + + test.debitAccount(500); + double expectedDebitBalance = 100500; + double actualDebitBalance = test.getBalance(); + Assert.assertEquals("Testing debit", expectedDebitBalance,actualDebitBalance,0); + + double expectedInterest = 2.5; + double actualInterest = test.getInterest(); + Assert.assertEquals("Testing Interest", expectedInterest,actualInterest,0); + } +}