A teenager has been convicted for having a knife and cannabis at a block of flats in Bradford.