]> matita.cs.unibo.it Git - logicplayer.git/blob - mainActivity/src/com/example/furt/myapplication/FormulaNot.java
f8b0d37662acb5febfa12758681b95ee7f091da6
[logicplayer.git] / mainActivity / src / com / example / furt / myapplication / FormulaNot.java
1 package com.example.furt.myapplication;
2
3 import android.graphics.Paint;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 public class FormulaNot extends GenericFormula implements Formula{
9     Paint p=new Paint();
10     Formula Operand;
11     int priority;
12     int argPriority;
13     FormulaNot(Formula F)
14     {
15         Operand=F;
16         priority=20;
17         argPriority=100;
18     }
19     @Override
20     public String Draw(int p)
21     {
22         if (priority >= p)
23             return "¬"+Operand.Draw(20);
24         else
25             return("¬("+Operand.Draw(20)+")");
26     }
27
28     public List<IntroductionRule> introductionRules(){
29         List<IntroductionRule> nodes=new ArrayList<IntroductionRule>();
30         RuleIntroduction notIntro=new RuleIntroduction("¬i",4);
31         Node notN=new Node(new FormulaBOT());
32         List<Formula> notHP=new ArrayList<Formula>();
33         notHP.add(Operand);
34         notN.addHPFormula(notHP,true);
35         Node thisNode=new Node(this);
36         thisNode.addChild(notN);
37         notIntro.tempRule=thisNode;
38         nodes.add(notIntro);
39         return nodes;
40     }
41     public List<EliminationRule> EliminationRules()
42     {
43         List<EliminationRule> nodes=new ArrayList<EliminationRule>();
44         nodes.add(new RuleNotElimination(this));
45         return nodes;
46     }
47
48     @Override
49     public boolean Fill(Formula Filler) {
50         if(Operand.toString().equals("_")) {
51             Operand = Filler;
52             return true;
53         }
54         return Operand.Fill(Filler);
55     }
56
57     @Override
58     public boolean setCursor() {
59         return Operand.setCursor();
60     }
61
62     @Override
63     public Formula duplicate() {
64         return new FormulaNot(Operand.duplicate());
65     }
66 }