How to create two classes in this logic (Python 3)

I want to create two separate classes (class doA and class doB) in the following logic using Python:

”’
x = 0
p = 0
while True:
doA
x = x + 1
while 1<=x<=15
if p < 0.5:
doA
x = x + 1
else:
doB
x = 0
while x > 15:
if p < 0.1:
pass
else:
doB
x = 0
”’
Is there any way to create two classes (doA & doB) that can apply the same logic?