Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Complier File
1. COMPLIER FILE
Submitted by: Pinak Mukherjee (038/CS/GTBIT/04)
Department of Computer Science and Engineering
Guru Tegh Bahadur Institute of Technology
2. /*Generation of code in c++ to add two numbers by coding in c*/
void main()
{char a[40],b[40],c[40],d[40];
clrscr();
do
{printf("Enter class name=>");
scanf("%s",a);
}while(strlen(a)>=40);
do
{printf("Enter name of first variable=>");
scanf("%s",b);
}while((!strcmp(a,b))||(strlen(b)>=40));
do
{printf("Enter name of second variable=>");
scanf("%s",c);
}while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40));
do
{printf("Enter name of class variable=>");
scanf("%s",d);
}while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40));
clrscr();
printf("class %s",a);
printf("n{n private:n");
printf(" int %s;n",b);
printf(" int %s;n",c);
printf(" public:n");
printf(" void getinput()n {");
printf("n cout<<"Enter first number:";");
printf("n cin>>%s;",b);
printf("n cout<<"Enter second number:";");
printf("n cin>>%s;",c);
printf("n }");
printf("n void addnos()n {");
printf("n cout<<"The Sum is:"<<%s+%s;",b,c);
printf("n }");
printf("n };");
printf("nvoid main()n {");
printf("n %s %s;",a,d);
printf("n %s.getinput();",d);
printf("n %s.addnos();",d);
printf("n }");
getch();
}
3. OUTPUT
Enter class name=>student
Enter name of first variable=>a
Enter name of second variable=>b
Enter name of class variable=>student1
class student
{
private:
int a;
int b;
public:
void getinput()
{
cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
}
void addnos()
{
cout<<"The Sum is:"<<a+b;
}
};
void main()
{
student student1;
student1.getinput();
student1.addnos();
}
4. /*Generation of code in java through code in c*/
void main()
{char a[40],b[40],c[40],d[40];
clrscr();
do
{printf("Enter class name=>");
scanf("%s",a);
}while(strlen(a)>=40);
do
{printf("Enter name of first variable=>");
scanf("%s",b);
}while((!strcmp(a,b))||(strlen(b)>=40));
do
{printf("Enter name of second variable=>");
scanf("%s",c);
}while((!strcmp(a,c))||(!strcmp(c,b))||(strlen(c)>=40));
do
{printf("Enter name of class variable=>");
scanf("%s",d);
}while((!strcmp(a,d))||(!strcmp(d,c))||(!strcmp(d,b))||(strlen(d)>=40));
clrscr();
printf("public class %s",a);
printf("private int %s;n",b);
printf("private int %s;n",c);
printf("public static void main(){n");
printf("n System.out.println("Enter first number:");");
printf("n cin>>%s;",b);
printf("n System.out.println("Enter second number:");");
printf("n cin>>%s;",c);
printf("n System.out.println("The Sum is:",%s+%s);",b,c);
printf("n }");
printf("n}");
getch();
}
OUTPUT
5. Enter class name=>STUDENT
Enter name of first variable=>A
Enter name of second variable=>B
Enter name of class variable=>STUDENT1
public class STUDENTprivate int A;
private int B;
public static void main(){
System.out.println("Enter first number:");
cin>>A;
System.out.println("Enter second number:");
cin>>B;
System.out.println("The Sum is:",A+B);
}
}
/* Program on lexical analysis */
#include"stdio.h"
#include"conio.h"
#include"string.h"
#include"ctype.h"
#define MAX 30
void main()
{
char str[MAX];
int state=0;
int i=0, j, startid=0, endid, startcon, endcon;
clrscr();
for(j=0; j<MAX; j++)
str[j]=NULL; //Initialise NULL
printf("*** Program on Lexical Analysis ***");
printf("Enter the string: ");
gets(str); //Accept input string
str[strlen(str)]=' ';
printf("Analysis:");
while(str[i]!=NULL)
{
while(str[i]==' ') //To eliminate spaces
i++;
switch(state)
{
case 0: if(str[i]=='i') state=1; //if
else if(str[i]=='w') state=3; //while
10. break;
case 24: if(isalnum(str[i]))
{
printf("== : Relational operator n");
state=0;
i--;
}
break;
//States for constants
case 25: if(isalpha(str[i]))
{
printf(" *** ERROR *** n ");
puts(str);
for(j=0; j<i; j++)
printf(" ");
printf("^");
printf("Error at position %d Alphabet cannot follow digit n", i);
state=99;
}
else if(str[i]=='(' || str[i]==')' || str[i]=='<' || str[i]=='>' || str[i]==NULL || str[i]==';' || str[i]=='=')
{
endcon=i-1;
printf(" ");
for(j=startcon; j<=endcon; j++)
printf("%c", str[j]);
printf(" : Constant n");
state=0;
i--;
}
break;
//State for special character '('
case 26: printf(" ( : Special character n");
startid=i;
state=0;
i--;
break;
//State for special character ')'
case 27: printf(" ) : Special character n");
state=0;
i--;
break;
//State for special character ';'
case 28: printf(" ; : Special character n");
state=0;
11. i--;
break;
//State for operator '+'
case 29: printf(" + : Operator n");
state=0;
i--;
break;
//State for operator '-'
case 30: printf("+ : Operator n");
state=0;
i--;
break;
//Error State
case 99: goto END;
}
i++;
}
printf("n End of program");
END:
getch();
}
/* Output
Correct input
-------------
*** Program on Lexical Analysis ***
Enter the string: for(x1=0; x1<=10; x1++);
Analysis:
for : Keyword
( : Special character
x1 : Identifier
= : Assignment operator
0 : Constant
; : Special character
x1 : Identifier
<= : Relational operator
10 : Constant
; : Special character
12. x1 : Identifier
+ : Operator
+ : Operator
) : Special character
; : Special character
End of program
Wrong input
-----------
*** Program on Lexical Analysis ***
Enter the string: for(x1=0; x1<=19x; x++);
Analysis:
for : Keyword
( : Special character
x1 : Identifier
= : Assignment operator
0 : Constant
; : Special character
x1 : Identifier
<= : Relational operator
Token cannot be generated
*/
OUTPUT
*** Program on Lexical Analysis ***Enter the string: if (a>b) a=25;
Analysis:if : Keyword
( : Special character
a : Identifier
> : Relational operator
b : Identifier
) : Special character
a : Identifier
= : Assignment operator
25 : Constant
; : Special character
End of program
13. /*Count number of characters, words, lines in a file */
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{ clrscr();
char ch,fname[50];
int count=0,ascii,line=0,words=0,previous=10;
cout<<"Enter the complete path of the file:"<<"n";
cin.get(fname,50);
fstream fio;
fio.open(fname,ios::in) ;
fio.seekg(0);
while(fio)
{ fio.get(ch);
if(ch !=10 && ch !=-1)
{
count++;
if(ch==32 && previous !=32)
{words++;
}
previous=ch;
}
else
{if(ch==10)
line++;
if (previous !=10 && previous != 32)
words++;
previous=ch;
}
ascii=ch;
cout<<ch<<":"<< ascii<<"n";
}
fio.close();
cout<<"number of characters:"<<count<<"n";
cout<<"number of lines:"<<line<<"n";
cout<<"number of words:"<<words<<"n";
getch();
14. }
OUTPUT
Enter the complete path of the file:
c:Documents and SettingsUser1Desktoptext.txt
number of characters:98
number of lines:4
number of words:26
*/ First and follow */
#include<iostream.h>
#include<conio.h>
struct prod
{ char left, right[10][10];
int no_prod;
};
struct firstnfollow
{ char ch[100];
int n_f;
};
void main()
{ clrscr();
prod p[]={{'E',{"TR"},1},
{'R',{"+TR","~"},2},
{'T',{"FD"},1},
{'D',{"*FD","~"},2},
{'F',{"(E)","i"},2}};
firstnfollow f1[10];
firstnfollow f2[]={{"$",1},{"",0},{"",0},{"",0},{"",0}};
int n=5; // int n=5;
char temp;
for(int i=0;i<n;i++)
{ for(int j=0;j<p[i].no_prod;j++)
{ f1[i].ch[j]=p[i].right[j][0];
f1[i].n_f=p[i].no_prod;
}
}
for(i=0;i<n;i++)
{ while(f1[i].ch[0]>=65&&f1[i].ch[0]<=90)
{ temp=f1[i].ch[0];
for(int j=1;j<f1[i].n_f;j++)
f1[i].ch[j-1]=f1[i].ch[j];
f1[i].n_f--;
for(int k=0;k<n;k++)
17. }
cout<<"nThe Follows are: ";
for(i=0;i<n;i++)
{ cout<<"n"<<p[i].left<<" ---- ";
j=0;
while(f2[i].ch[j]!='0')
{ cout<<f2[i].ch[j]<<" ";
j++;
}
}
getch();
}
OUTPUT
The Firsts are:
E ---- ( i
R ---- + ~
T ---- ( i
D ---- * ~
F ---- ( i
The Follows are:
E ---- $ )
R ---- $ )
T ---- + $ )
D ---- + $ )
F ---- * + $ )