Wednesday, September 2, 2020

variables in java

 Today we will explain primitive data types , arithmetic operators and variables in java 

 Data types : 

byte, short, int and long data types are used for storing whole numbers.

float and double are used for fractional numbers.

char and string which are used for storing characters(letters).

boolean data type is used for variables that holds either true or false
 
 
 
 
variables :
     variable is a name of reserved area in the computer's memory or it's a name of memory location , an d we have three main types of variables in java 
  • local variables : which are defined inside some method's body
  • instance variables : which are defined out side method body , but in side class body 
  • static variables : which are defined by using "static" word before we defined them , and they can not be defined inside method body
Now :  we can define any variable as bellow 
 
data_type variable_name = value;
 
 
arithmetic operators : 

  
 
 
Now let us go to our example today , and we will explain the code which it's output just as in the image bellow 
 
 
 and the code will be just as 

public class test{
    public static void main(String[]args){
        int num = 10;
        System.out.println("________________________");
        System.out.println();
        System.out.println("      "+num+" * 1 "+" = "+num*1);
        System.out.println("      "+num+" * 2 "+" = "+num*2);
        System.out.println("      "+num+" * 3 "+" = "+num*3);
        System.out.println("      "+num+" * 4 "+" = "+num*4);
        System.out.println("      "+num+" * 5 "+" = "+num*5);
        System.out.println("      "+num+" * 6 "+" = "+num*6);
        System.out.println("      "+num+" * 7 "+" = "+num*7);
        System.out.println("      "+num+" * 8 "+" = "+num*8);
        System.out.println("      "+num+" * 9 "+" = "+num*9);
        System.out.println("      "+num+" * 10 "+" = "+num*10);
        System.out.println("      "+num+" * 11 "+" = "+num*11);
        System.out.println("      "+num+" * 12 "+" = "+num*12);
        System.out.println();
        System.out.println("_________________________");
        System.out.println();
        System.out.println();
        System.out.println();
    }
}

 
Home Work ?
write a java code that give the output in the image bellow 
 

 
 
 

Sunday, August 30, 2020

java's principles

java

Today we will start coding java , but first we must explain some important thing and principles 
 
Package : is a mechanism to encapsulate a group of classes, sub packages and interfaces and package can be used for 
  • Preventing naming conflicts
  • Making searching/locating and usage of classes, interfaces, enumerations and annotations easier
  • Providing controlled acces
packages in java has two main types :
  • Built-in Packages : These packages consist of a large number of classes which are a part of Java API ( java.lang ,  java.io ,  java.util)
  • User-defined packages : These are the packages that are defined by the user
Class : is a user defined blueprint or prototype from which objects are created , has (Modifiers , Class name , Superclass , Interfaces, Body )

Method : is a collection of statements that are grouped together to perform an operation
 
 Compiler : is a program that takes the text file work of a developer and compiles it into a platform-independent Java file. Java compilers include the Java Programming Language Compiler (javac), the GNU Compiler for Java (GCJ), the Eclipse Compiler for Java (ECJ) and  Jikes.
 
Error in programming : 
  • Syntax errors : These are errors where the compiler finds something wrong with your program, and you can't even try to execute it
  • Runtime errors : Java may detect an error while your program is running 
  • Logic errors : logic error, or bug, is when your program compiles and runs, but does the wrong thing. The Java system, of course, has no idea what your program is supposed to do, so it provides no additional information to help you find the error 
Now we can go to write our first java program which has the output just like in the image bellow  
 

___________________________________________
 
this is the code , and we explain it on the video bellow 
 
public class test{
    public static void main(String[]args){
        System.out.println("____________________________________________________________________");
        System.out.println();
        System.out.println("                         Wellcome To Java");
        System.out.println();
        System.out.println("____________________________________________________________________");
        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println();
    }
}

 
watch on YouTube
 
 

 
PREVIOUS STEP         NEXT STEP

Tuesday, June 16, 2020

Introduction To Java

JAVA

Computer & Programs :

Programing means to create a software which is contain the instructions that tell the computer or any other computerized device what to do , and this instructions called the program , so the program is a set of instructions that are telling the computer what to do , in order to do some tasks


         Computer is an electronic device that stores and processes data ,and it is consist of hardware and software

The hardware of the computer contain

A central processing unit (CPU) >> the computer’s brain and it’s contain of two main units ( the control unit which is coordinating the action , and the logic unit which is performs the numeric operations

Memory store the programs and its data

I/O devices

Communication devices , which are help the computer to networking and communicated with the other computers and computerized devices

Storage devices

The software which are the programs and software that are stored in the computer



Programing languages :

         The computer can’t understand the human language , so to make the human communicate with the computer they must use some language that the computer can understand

Machine Language : is the computer language that its instructions written in binary code just as 01101100

Assembly Language : Assembly language uses a short descriptive word, known as a mnemonic, to represent each of the machine-language instructions

Assembler : is a program that used to translate assembly-language program into machine code




Assembly Language known as low level programming language because it’s close in the nature to machine language & is machine dependent

High level programing languages

Start at 1950s

Platform dependent which means you can write your program and run it in different types of machines

Just as English text

EG : area =9*9*3.14159



High level programing language as

Java
++C
#C
python
C
Cobol
Pascal
Basic

Introduction to java

Java is a powerful and versatile programming language for developing software running on mobile devices, desktop computers, and servers.

developed by a team led by James Gosling in 1991 at Sun Microsystems. Sun Microsystems was purchased by Oracle in 2010 , was called Oak , and renamed to java at 1995

Java is a full-featured, general-purpose programming language

Java initially became attractive because Java programs can be run from a Web browser applets

The application program interface (API), also known as library, contains predefined classes and interfaces for developing Java programs ,and it’s still expanded

Java Development Toolkit is called JDK , set of separate programs, each invoked from a command line, for developing and testing Java programs

Instead of using the JDK, you can use a Java development tool (e.g., NetBeans, Eclipse, and TextPad) software that provides an integrated development environment (IDE) for developing Java programs quickly


to download textpad :

https://www.textpad.com/download/

to download JDK :

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

 

watch on YouTube


 

NEXT STEP

Saturday, April 25, 2020

orm methods in odoo

ODOO

ORM

 
ORM Methods in odoo :
  • ORM is stands for Object Relational Mapping 
  • Used to convert data between incompatible type system
  • Odoo modeling is based on "objects" but it's data is stored in a classical relational database 

žsearch()

 
           Use to search for records in object
ž           Input > search domain
ž           Output > list of ids
ž           Employee_ids = self.env[‘hr.employee’].search([‘age’,’=‘,65])

browse()  



žUse to get record set
žInput > list of ids
žOutput > record set
žfaculty =  self.pool.get('op.faculty').browse(self.cr, self.uid, faculty_id)

 create()


ž           Used to create new records in object
ž           Input > field’s values
ž           Output > create new reord in object
ž           Employee_id = self.env[‘hr.employee’]
ž           Employee_ids.create({‘name’:Juhn,’age’:28,’gender’:’male’})

write()


ž          Used to write our update values of records
ž          Input > field’s values
ž          Output > write these values to all records in it’s record set
ž          Employee_id = self.env[‘hr.employee’].search([(‘id’,’=’,1)])
ž          Employee_ids.write({‘name’:’mark’,’age’:38})
            Write () with relational fields
            0, 0, { values }) link to a new record that needs to be created with the given values dictionary
ž(1, ID, { values }) update the linked record with id = ID (write values on it)
ž(2, ID) remove and delete the linked record with id = ID
ž(3, ID) cut the link to the linked record with id = ID
ž(4, ID) link to existing record with id = ID (adds a relationship)
ž(5) unlink all (like using (3,ID) for all linked records)
ž(6, 0, [IDs]) replace the list of linked IDs
  

exists()


žReturns a new recordset containing only the records which exist in the database
žif not record.exists(): raise Exception("The record has been deleted")

ensure_one ()

           checks that the recordset is a singleton
self.ensure_one()

PREVIOUS STEP                    NEXT STEP

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...