الأسايمنت جافا الأولي
الأسايمنت جافا الأولي
الأسايمنت جافا الأولي
Registration Number:
(JG97374)
Assignment No. 1 of 1
Program Title Pearson BTEC Level 5 HND Diploma in Computing and Systems Developme
1.1................................................................................................................................................................................... 5
1.2................................................................................................................................................................................. 15
TASK 2.........................................................................................................................................................................17
2.1................................................................................................................................................................................. 17
2.2................................................................................................................................................................................. 21
Task 3.......................................................................................................................................................................... 23
3.1................................................................................................................................................................................. 23
3.2................................................................................................................................................................................. 24
3.5................................................................................................................................................................................. 25
3.6................................................................................................................................................................................. 25
Task 4.......................................................................................................................................................................... 27
4.1................................................................................................................................................................................. 27
4.2................................................................................................................................................................................. 28
4.3................................................................................................................................................................................. 28
4.4................................................................................................................................................................................. 29
Gantt chart
1.1
Characteristics:
Java is a global language that is widely distributed and also known as object oriented
Also help in designing games and creating programs with graphical user interface
You can achieve the required benefit from all Internet features
It also enables us to create programs for personal and professional use. These programs are
performed through a variety of editors or environments that facilitate the writing of commands such
as : NetBeans IDE , Eclipse
It is a statment used frequently to execute commands , they contain templates for creating objects
and for determining the methods and types of object data all class objects must contain the
properties of the base class , Because classes are categories , and entities are elements within
each category
Then the name of the class (class name), the keywords and finally the text of the printed code
within the brackets { }
On the example, the table is an object, the object book, The person is an object
- Of course, Applet programs are executed when a user opens a Web site in any browser that is
supported by Java and is done within the browser window , The Applet can also play multimedia in
formats not supported by the browser
Windows Media Player uses the Applet to display video files embedded in browsers
A great reason to choose Java is the ecosystem, because Java provides a very rich API that is
characterized by the presence of layers
There is a good number of Mutawites working to improve them, making them excel in a number of
languages
Inheritance
Is the process by which one acquires characteristics (Methods& fiels) of another party through
inheritance, the information is made controllable in hierarchical order
The class that acquired the attributes is called a Sub class(Child class)
The class that inherits its properties is called a Super class (Parent class)
class Super {
.....
.....
.....
.....
Using extends keyword, the My_Calculation inherits the methods addition() and Subtraction() of
Calculation class.
Copy and paste the following program in a file with name My_Calculation.java
class Calculation {
int z;
z = x + y;
z = x - y;
z = x * y;
demo.addition(a, b);
demo.Subtraction(a, b);
demo.multiplication(a, b);
Output
In the given program, when an object to My_Calculation class is created, a copy of the contents
of the superclass is made within it. That is why, using the object of the subclass you can access
the members of a superclass.
Encapsulation
is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism,
and abstraction.
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the
data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden
from other classes, and can be accessed only through the methods of their current class.
Therefore, it is also known as data hiding.
Provide public methods (set and get) to modify and display variable values
We have example :
return age;
return name;
return idNum;
age = newAge;
name = newName;
idNum = newId;
public set () and get () methods are the access points of the instance variables of the EncapTest
class. Normally, these methods are referred as getters and setters. Therefore, any class that
wants to access the variables should access them through these getters and setters.
The variables of the EncapTest class can be accessed using the following program –
encap.setName("James");
encap.setAge(20);
encap.setIdNum("12343ms");
Output
Benefits of Encapsulation
data structure:
Data types: Specifies the values that the variable takes if the variable contains data of type int
This means that it can only take data from a valid type
2 - Types of non - primitive data: such as strings and matrices are all types of non - primitive data
First, we will talk about primitive data types: the data of the variable must be specified before it is
called (declarate the variables)
Int num ;
It is the approach followed with all variables at the beginning of each program
- Knowing that the size of primitive data types does not change from one operating system to
another
Integer:
We use int when the data type is "short" is insufficient to accommodate the number
Default value : 0
For example :
Example:
class JavaExample {
System.out.println (num);
Output:
-4.29377379E7
MAZEN OBAIDEEN Unit 17 Page 13 of 33
Boolean
It expresses the logical amount with two values, either true or false
Boolean values are used in branch statements to verify the validity of the contained logical
expression .
Size: 16 bit
Represents an unicode value , each printable and nonprintable character has a Unicode value
because Java language works on storing characters as unicode, can be used with any language
written in the world
One dimensional array is a list of same typed variables. To create an array, first you must declare
an array variable of required type
Declaring an matrix is the same way of declaring a variable but with an extra square brackets. To
inform the compiler, that the variable represents an array, suffix or prefix (Java allows) the variable
name with a pair of square brackets. Array size should be given at the time of creation itself.
Depending upon the size, continuous memory locations are allocated to the elements. Array
identifier follows the same rules of Java identifiers.
arrayRefVar=new datatype[size];
class Testarray{
a[0]=10;//initialization
a[1]=20;
a[2]=70;
a[3]=40;
a[4]=50;
System.out.println(a[i]);
Output:
10
20
70
40
50
Two-dimensional arrays are defined as "an array of arrays". Since an array type is a first-class
Java type, we can have an array of ints, an array of Strings, or an array of Objects , we can index
Two-dimensional (2D) arrays by two subscripts, one for the row and one for the column.
class MultidimensionalArray {
int[][] a = {
{1, 2, 3},
{4, 5, 6, 9},
{7},
};
Length of row 1: 3
Length of row 2: 4
Length of row 3: 1
1.2
Java is a flexible language for several reasons
Portable: You can transfer the code written in Java from one computer to another without fear of
system configuration details
Security: When compiled, the source language written in Java is compiled into (bytecode)
Which is later interpreted by the Java virtual machine , in addition Java security technology
includes a large set of APIs, tools, and implementations of commonly used security algorithms,
mechanisms, and protocols.The Java security APIs span a wide range of areas, including
cryptography, public key infrastructure, secure communication, authentication, and access control.
Safety technology for the developer provides a comprehensive security framework for writing
applications.
It works on all common systems where JVM is present , this applies to Mac OS, Linux, Windows
High performance: Java has proven to be powerful in terms of efficiency and memory
Contribute to the development of Java with advanced and advanced APIs and libraries, available
as ready-to-use packages for the creation of reliable and robust network systems
JVM
Java Virtual Machine: the default Java language,feature built in Java language
Function: Enable various computers to run programs written in Java and can be said that JVM is a
default processor
3. Execution Engine
Byte code
Is an intermediate language that interprets source codes from a high-level language into a low-
level language (machine language)
But if we move this code to another operating system, the machine language will be different
We convert the code to the bytecode and then from the bytecode to the machine we will work on
2.1
A.
B.
First :
Second
Commercial Customer:
A subclass is called , it has own attributes and such as the consumption the parent class can not
access , The same thing for methods
Residential Customer:
Such as consumption according to the time period and Superclass (client) can not access to it
The idea is that the features of the customer are automatically generated at (commercial and
domestic) any subscriber
Hence any method found at the Superclass can subclass , To reach her but the reverse is
incorrect
C.
D.
Flow chart :
I have two types of commercial invoice and home so I resorted to inheritance and designed
Superclass and subclass
We have 4 Classes:
They :
1-main class
2- commercial class
3- residential class
4- client class
1-class client
-Attribute:
Int no : It means that I have declared a variable of type (integer) for one of the customer
registration information , which is (customer number)
String name :
String name :It means defining or declaring a string variable for a registration information
It is a (name)
Int counter id :The declaration of an int variable for one of the customer registration data (counter
number)
Int year : The declaration means a variable of type (int), which expresses the year of issuing the
invoice (year number id)
Int month : The declaration of a variable of type (int), which expresses the number of the month in
which the invoice (month number)
Void view ( )
Attributes :
Int consumption: declare a variable of type (Double) for the amount of consumption according to
the commercial invoice
Methods:
Double solve () : Is a method that calculates the cost or value of the exchange of electricity based
Attributes :
Consumption 6 → 5: It is a variable of type (Double) that defines the second consumption period
from 6 pm to 5 am
Consumption 5 → 10: It is a variable of type (Double) to define the period of the third consumption
she is from 5 am to 10 pm
Methods:
Double solve ( ) : It is a double type that calculates the value or cost of the exchange of electricity
based on the specific consumption periods.
3.1
Main Class :
- And with this beautiful library it offers many functions that can be used to get
Confirm dialogs – input dialogs– message dialogs
3.4
The general concept is Java-oriented IDE , It needs to work as a Java virtual machine
Netbeans is an open source program that is used by a large number of programmers and
developers and I am also used to it as the main editor of Java code
Netbeans IDE : Also known as the software developer with a graphical interface and is an
integrated software environment that supports a variety of programming languages, including
PHP, java
Developed in Java and provides great features such as: Monitoring of grammatical errors - alerting
the programmer in case of writing a wrong expression or forgetting an arc or semicolon, for
example in one of the lines of code
It is worth mentioning that the program is completely free and without any restrictions on its use
and works on all known systems without problems
3.6
General framework of the program is design and development of Java application for Electra
It works at the expense of the bill of electricity for customers, and are two types according to the
following scenario:
First: Customer information and data must be recorded in the company as:
The invoice must contain the number of the month in which the invoice was issued and the year
According to a schedule that determines the amount of consumption in kilowatts (from ... to) in
exchange for an amount imposed for each kilowatt estimated in (TL)
Depending on the consumption period 3 periods (morning - afternoon - evening) are arranged
according to the schedule in consecutive hours
An ordinary user can work on the program using the graphical user interface (GUI), making the
application more user friendly and flexible
Or you can add a simple control module in the form of a dialog box containing all entries
necessary for all functions (console)
3- Help
4- Exit
4.1
After checking and testing the code, you have corrected some simple spelling mistakes
but I did not notice any errors in the code in the code call to reduce or disrupt the work of the
program
The definition of variables (declaration) and their attribution of values is true so that I did not begin
to declare the variables using numbers
also, make sure not to leave blank spaces in the name of the variable (if it is more than one word).
to avoid this error, add an underscore (_)symbol or the words can be connected immediately
because of the conditions of the variables start with a letter or underscore or $ and do not initiate a
number
Include a document or text file to help the user learn and understand the program easily
In reviewing the program, it was confirmed that the variable names were identical in the different
classes
Also, methods and classes were arranged and organized and therefore subject to the correct rules
and conditions
Append annotations Adding a task at the programmer level and arranging the lines under each
one increases the visibility and aesthetics of the code
I've included a text document or report to help the user use the program easily and understand
how it works
4.2
I can add other classes to the program to calculate the value or amount of customer consumption
per month and another class calculated the total annual consumption plus the value of the invoice
by 12 months for the residential customer
- The last date for the payment of the invoice may be placed with the client's notice of the
existence of fines in the event of a delay of one week from the payment
As well as the attributes of the client can add a phone number + place of residence
4.4