Object Oriented Programming Basics for the BKT Client - MISC
Thu Sep 01, 2016 3:25 am
Rectangle \This is your (Class)
---------------
length: real \\THESE ARE (Data Members)
breadth: real
----------------
are(): real
perimeter(): real \\\These are (Methods)
diagnol(): real
isSquare(): boolean
shorterSide(): real
longerSide(): real
equals(rectangle): boolean
--------------------------------
Normally a CLASS of an object is written with the first character as a capital. Such as Rectangle not "rectangle"
Reason why you write Rectangle with a capital is to defirentiate it to be a CLASS.
---------------
length: real \\THESE ARE (Data Members)
breadth: real
----------------
are(): real
perimeter(): real \\\These are (Methods)
diagnol(): real
isSquare(): boolean
shorterSide(): real
longerSide(): real
equals(rectangle): boolean
--------------------------------
Normally a CLASS of an object is written with the first character as a capital. Such as Rectangle not "rectangle"
Reason why you write Rectangle with a capital is to defirentiate it to be a CLASS.
Important Instance Methods for Strings
Thu Sep 01, 2016 3:35 am
Important Methods for String data types:
.charAt(int) : char
.indexOf(char): int
.indexOf(String): int
.substring(begin): String
.toLowerCase(): String --> ("HelLO BKT" --> becomes "hello bkt");
String s = "Finally";
String t = s.substring(0, 5) + "_bkt"; //This method returns "Final"+"_bkt"
This then gets concatanated and becomes "Final bkt"
String greeting = new String ("hello bkt client");
String ("hello bkt client") --> this is a REFERENCE
greeting --> this is the OBJECT
Also key note a String can be thought of a CHARACTER ARRAY, like so (in a string of "Hello") the character array would be:
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
.charAt(int) : char
.indexOf(char): int
.indexOf(String): int
.substring(begin): String
.toLowerCase(): String --> ("HelLO BKT" --> becomes "hello bkt");
String s = "Finally";
String t = s.substring(0, 5) + "_bkt"; //This method returns "Final"+"_bkt"
This then gets concatanated and becomes "Final bkt"
String greeting = new String ("hello bkt client");
String ("hello bkt client") --> this is a REFERENCE
greeting --> this is the OBJECT
Also key note a String can be thought of a CHARACTER ARRAY, like so (in a string of "Hello") the character array would be:
[0] = 'h'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
Re: Object Oriented Programming Basics for the BKT Client - MISC
Thu Sep 01, 2016 3:47 am
- Code:
public class Rectangle {
public double width, height; //My clients data members
public double area(){ //My clients methods
return width * height;
}
}
If you want to import certain methods such as pi, type Math.pi
or Math.Cosine to find the Cosine of a triangle.
- Ricardo HarerraGroup Moderator
- Posts : 52
Points : 128
Forum Reputation : 22
Join date : 2016-07-20
Location : Mexico,Ciudad Juárez
Re: Object Oriented Programming Basics for the BKT Client - MISC
Fri Sep 02, 2016 2:49 pm
Thisi s for the client im guessing?
Permissions in this forum:
You cannot reply to topics in this forum
|
|