Showing posts with label ITC255. Show all posts
Showing posts with label ITC255. Show all posts

Sunday, August 4, 2019

Classes and tests Code Testing video

lock.py

class Lock():
    def __init__(self, door, location,securitylevel):
        self.door=door
        self.location=location
        self.securitylevel=securitylevel
        self.status='locked'

    def setStatus(self, status):
        self.status=status

    def getStatus(self):
        return self.status

    def getDoor(self):
        return self.door

    def getLoction(self):
        return self.location

    def getSecurityLevel(self):
        return self.securitylevel

    def __str__(self):
        return str(self.door) + " " + self.status

scan.py

from lock import Lock
import datetime

class Scan():
    def __init__(self, door, location, securitylevel, card):
        self.lock=Lock(door,location,securitylevel)
        self.card=card
        self.scantime=datetime.datetime.now()
    
    def getLock(self):
        return self.lock
    
    def getCard(self):
        return self.card

    def getScanTime(self):
        return self.scantime

The Tests: test.py

import unittest
from lock import Lock
from scan import Scan

class LockTest(unittest.TestCase):
    def setUp(self):
        self.lock=Lock('3176','BE', 'normal')

    def test_lockstring(self):
        self.assertEqual(str(self.lock), '3176 locked')

    def test_getStatus(self):
        self.assertEqual(self.lock.getStatus(), 'locked')

    def test_setStatus(self):
        self.lock.setStatus('unlocked')
        self.assertEqual(self.lock.getStatus(), 'unlocked')
    
    def test_GetDoor(self):
        self.assertEqual(self.lock.getDoor(), '3176')

class ScanTest(unittest.TestCase):
    def setUp(self):
        self.scan=Scan('3176', 'BE', 'normal', 315643)

    def test_GetCard(self):
        self.assertEqual(self.scan.getCard(), 315643)

Friday, June 28, 2019

Tuesday, June 4, 2019

Testing

here is the code for the tests. the tests and the classes being tested are available on github.com/spconger

import unittest
from item import Item
from orderitem import OrderItem
from order import Order
from payment import Payment

class ItemTest(unittest.TestCase):
    def setUp(self):
        self.item=Item(1,'item1', 30.00)
    
    def test_string(self):
        self.assertEqual(str(self.item), self.item.itemname)

    def test_GetItemNumber(self):
        self.assertEqual(self.item.getItemNumber(),1)

    def test_GetItemPrice(self):
        self.assertEqual(self.item.getItemPrice(),30.00)

class OrderItemTest(unittest.TestCase): 
    def setUp(self):
        self.item=Item(1,'item1', 30.00)
        self.oitem=OrderItem(self.item,2)

    def test_Quantity(self):
        self.assertEqual(self.oitem.getQuantity(),2)
    
    def test_item(self):
        item=self.oitem.getItem()
        self.assertEqual(str(item), 'item1')

class OrderTest(unittest.TestCase):
    def setUp(self):
        self.item1=Item(1,'beer',6.25)
        self.item2=Item(2,'chips', 4.50)

        self.orderitem1=OrderItem(self.item1,2)
        self.orderitem2=OrderItem(self.item2,1)

        self.order=Order()
        self.order.addOrderItems(self.orderitem1)
        self.order.addOrderItems(self.orderitem2)

    def test_CalculateTotal(self):
        payment=self.order.calcTotal()
        self.assertEqual(str(payment), 'Your payment today will be 17.0')

Tuesday, May 28, 2019

SalesExample

Here is the class diagram for the salesExample

Here is the link to the diagram https://www.lucidchart.com/invitations/accept/409c3b2a-7232-4813-a321-d66c508d3392

Here is the github link for the sales classes

Here is the github link for the lock classes

Thursday, May 23, 2019

Sequence diagrams

Here is the link to the Sales Example code in github. https://github.com/spconger/SaleExamples

The Sales Example Sequence diagram

The login sequence

The login with alternatives sequence

Tuesday, May 14, 2019

Class relations

Lock classes and relationships

Inheritance

User Class

class User():
    def __init__(self,name, email, securityLevel):
        self.name=name
        self.email=email
        self.securityLevel=securityLevel

    def getName(self):
        return self.name
    
    def getEmail(self):
        return self.email

    def getSecurityLevel(self):
        return self.securityLevel

    def __str__(self):
        return self.name + ", " + self.email

Staff Class

from user import User

class Staff(User):
    def __init__(self, name, email, securityLevel, position):
        self.name=name
        self.email=email
        self.securityLevel=securityLevel
        self.position=position

    def getPosition(self):
        return self.position

    def __str__(self):
        return super(Staff, self).__str__() + ", " + self.position

main

from staff import Staff
def setUser():
    s=Staff('Sue', 's@gmail.com', 'high', 'Janitor')
    print(s.getEmail())
    print(s.getName())
    print(s)

def main():
    setUser()

main()

Tuesday, April 30, 2019

Class diagram

Just a note: the video for this did not record

Background

GW-Basic, Fortran, Cobol, Top to bottom
hard to debug, not reusable Goto
Structured programming c pascal ADA functions
code reuse -- call function, debugging was easier
Objects --break the code into natural groups of functions that
reflect the structure of what you are working with
door(lock), card, scan, user, validation,
Object contains fields and methods
C++, Java, C#, Objective C
Python, php, JScript, ruby

Theory

Abstraction--abstract classes, interfaces
Encapsulation--lego idea-- every class should be self contained,
internal should be private
Inheritance--get all the public fields and
methods from the parent classes
Polymorphism--different behaviors for different environments
Overriding and overloading

Diagrams

User Class

Lock Class

More complete diagram

Tuesday, April 23, 2019

Activity diagram

Manage access activity diagram

Security alert

Security Alert

Forks and Joins

Thursday, April 11, 2019

Use cases

Locks ERD

Here is the link to the use case diagrams

Security Use case

Inheritance

Written Use Case 1

Written Use case 2

Thursday, April 4, 2019

Class Discussion ERD

Security system uses key cards.

People (administrator,students, staff,faculty, Custodial, security)

Departments

Rooms--locks

Security levels--people--rooms--server, computer labs

Smart cards: info is on the card

*Dumb cards--just a number--

Which card has access to which rooms at which times

Grouping of rooms

emergency opening and locking of doors

log every swipe--logging card number and lock

Alert if door open --swipe three times and fail

Here is a a picture of the ERD

here is the link to the ERD in LucidCharts

Systems Beginning

Definition: A System consists of parts that work together to accomplish a task or goal

A car engine, a computer, a body, an economy, or a planet's ecology can be a system

Definition: a sub system is a set of components that work together to accomplish a task or goal which contributes to the larger system.

Examples, the fuel or electrical systems of an engine, the circulatory system, the supply system, the water cycle.

Systems Analysis consists of identifying systems and their purpose, and the identifying--breaking them into--their component parts and determining how those parts interact with the whole.

The idea is to break complex processes into simpler pieces that can be understood and manipulated much more easily than the system as a whole.

The various techniques of systems analysis were developed to aid this process and increase the chances of success.

Most attempts to create and replace systems fail.

Reasons for Analysis

Typically one analyzes a system in order to understand some business process in order to automate it or improve the existing automation

The first steps would be to identify the system to be considered and its outcomes.

Then you would define the requirements of the replacement system

Thirdly you would identify any number of possible solutions that meet those requirements. You would analyze the feasibility of each potential solution financially,temporally , technologically, legally and culturally.

That done, you would choose one and setup a project with the timeline, personnel and resources to complete the project.

Then you test the product, fix any errors and deploy it. After deploying it, you maintain it until such a point as the process needs to start over.

In most contemporary organizations, systems are monitored continuously. Analysis, development, deployment and maintenance are all happening simultaneously.

Tuesday, May 29, 2018

Testing

Here is a picture of the code testing worksheet

Here is a link to the Fraction code on github

Tuesday, May 22, 2018

UML Diagrams for Venue

Use Case

Activity

Class Diagrams

Sequence

Tuesday, May 15, 2018

Thursday, May 3, 2018

More Class relations

Here is our interface

public interface I_items {
   public void addItem(Item i);
   public void removeItem(Item i);
}

Here is the code for a class that implements that interface

import java.util.ArrayList;

public class Inventory implements I_items{
  private ArrayList<Item> items;

@Override
public void addItem(Item i) {
 // TODO Auto-generated method stub
 
}

@Override
public void removeItem(Item i) {
 // TODO Auto-generated method stub
 
}
  
}

Here is the diagram for the card game program

Here is the link to the card game code on GitHub

Tuesday, May 1, 2018

Object Oriented principles

4 principles of OOPs
Inheritance--general-->more specific--code reuse
Encapsulation--seperation of concerns--every class should be self 
contained, as few dependencies as possible
Polymorphism--adapt and behave differently depending on environment
--overloading methods, overriding methods--generics
Abstraction--generalize, group everthing that is common

4 Types of Relationships
Inheritance
Association
Composition
Aggregation

Here is the diagram that shows the inheritance hierarchy

Here are the code classes that show that inheritance

Person Class

package com.spconger;

public abstract class Person {
 private String number;
 private String name;
 private String email;
 private String phone;
 
 public String getNumber() {
  return number;
 }
 public void setNumber(String number) {
  this.number = number;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getEmail() {
  return email;
 }
 public void setEmail(String email) {
  this.email = email;
 }
 public String getPhone() {
  return phone;
 }
 public void setPhone(String phone) {
  this.phone = phone;
 }

}

The Customer Class

package com.spconger;

import java.util.ArrayList;

public class Customer extends Person{
 ArrayList<String> coupons = new ArrayList<String>();
    public void AddCoupons(String coupon){
     coupons.add(coupon);
    }
    public String toString(){
     return getName();
    }
}

The EmployeeClass

package com.spconger;

public abstract class Employee extends Person {
  private String position;
  private String hireDate;
public String getPosition() {
 return position;
}
public void setPosition(String position) {
 this.position = position;
}
public String getHireDate() {
 return hireDate;
}
public void setHireDate(String hireDate) {
 this.hireDate = hireDate;
}
  public double calculatePay(){
   return 0.0;
  }
}

The SalaryEmployee Class

package com.spconger;

public class SalaryEmployee extends Employee{
 private double salary;

 public double getSalary() {
  return salary;
 }

 public void setSalary(double salary) {
  this.salary = salary;
 }
 
 public double calculatePay(){
  return getSalary()/12;
 }
 
}

Program Class

package com.spconger;

import java.util.Scanner;

public class Program {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Customer c = new Customer();
  c.setName("George");
  
  SalaryEmployee se = new SalaryEmployee();
  se.setName("Jenny");
  se.setSalary(30000.00);
  
  System.out.println(se.getName() + "," + se.getSalary() 
  + ", " + se.calculatePay());
  
  System.out.println(c.toString());
 }

}

Composition and Aggregation Diagrams

Wednesday, April 25, 2018

Class Diagrams 1 for Show Tracker

Here are my class diagrams for show tracker. This is a first take and I expect to modify these classes as we discuss them. One change from class is that I have moved the announcement methods have been moved to the Venue class, because I think Venues are logically in control of shows.

Tuesday, April 17, 2018

Activity diagrams

Here is the first login diagram

Here is the new show diagram

Here is a diagram that shows the split and join. Split implies threading--two things happening simultaneously

Here is the login with swim lanes. Swim lanes establish what areas are responsible for what actions

Thursday, April 5, 2018

Use Cases 1

Here are the use cases we did in class