public class Human {
public String Name;
public Integer Age;
public Human(){
this.Age = 0;
}
public void setName(String Name){
this.Name = Name;
}
public void setAge(String Name){
this.Age = Age;
}
public void Run(){
System.debug('Run');
}
public void Jump(){
System.debug('Jump');
}
public void Climb(){
System.debug('Climb');
}
}
// Remove class from body tag
function alpha_body_class($classes){
unset($classes[array_search('class-one', $classes)]);
unset($classes[array_search('class-two', $classes)]);
unset($classes[array_search('class-three', $classes)]);
return $classes;
}
add_filter('body_class', 'alpha_body_class');
public class Sale {
public String messageId;
public String eventId;
public Decimal eventSchemaVersion;
public String eventInstanceOriginationDateTime;
public SaleEventData eventData;
}
public class SaleEventData {
public Integer siteId;
public Integer saleId;
public String purchasingClientId;
public List<PaymentDetails> payments;
public String saleDateTime;
public String soldById;
public String soldByName;
public Integer locationId;
public Integer totalAmountPaid;
public List<SaleItemDetails> items;
}
public class PaymentDetails {
public Integer paymentId;
public Integer paymentMethodId;
public String paymentMethodName;
public String paymentAmountPaid;
public Integer paymentLastFour;
public String paymentNotes;
}
public class SaleItemDetails {
public Integer itemId;
public String type;
public String name;
public Integer amountPaid;
public Integer amountDiscounted;
public Integer quantity;
public String recipientClientId;
public Integer paymentReferenceId;
}
Sale mbSale = (Sale)JSON.deserialize(jsonInput, Sale.class);
{
"swagger": "2.0",
"basePath": "/",
"info": {
"version": "1.0",
"title": "External Service for demo bank",
"description": "### External Service for demo bank",
"x-vcap-service-name": "DemoBankRestServices"
},
"securityDefinitions": {
"basicAuth": {
"type": "basic"
}
},
"security": [{
"basicAuth": []
}],
"tags": [{
"name": "DemoBankRestServices"
}],
"paths": {
"/accounts/{accountName}": {
"get": {
"operationId": "getAccount",
"summary": "Retrieves an account",
"description": "Retrieves the account with specific name",
"consumes": ["text/plain"],
"produces": ["application/json"],
"parameters": [{
"name": "accountName",
"in": "path",
"required": true,
"type": "string",
"description": "Name of the account"
}],
"responses": {
"200": {
"description": "The response when system finds an account with given name",
"schema": {
"$ref": "#/definitions/accountDetails"
}
},
"400": {
"description": "Error response if the account name parameter is less than minimum characters",
"schema": {
"$ref": "#/definitions/errorModel"
}
},
"404": {
"description": "Error response if the account is not supported by service or account is not found",
"schema": {
"$ref": "#/definitions/errorModel"
}
}
}
},
"delete": {
"operationId": "DeleteAccount",
"summary": "Deletes an account",
"description": "Deletes the account with specific name",
"consumes": ["text/plain"],
"produces": ["application/json"],
"parameters": [{
"name": "accountName",
"in": "path",
"required": true,
"type": "string",
"description": "Name of the account"
}],
"responses": {
"204": {
"description": "The response when system finds an account with given name",
"schema": {
"type": "string"
}
},
"400": {
"description": "Error response if the account name parameter is less than minimum characters",
"schema": {
"$ref": "#/definitions/errorModel"
}
},
"404": {
"description": "Error response if the account is not supported by service or account is not found",
"schema": {
"$ref": "#/definitions/errorModel"
}
}
}
},
"post": {
"operationId": "addAccount",
"summary": "Add an account",
"description": "Add an account to the database",
"consumes": ["text/plain"],
"produces": ["application/json"],
"parameters": [{
"name": "accountName",
"in": "path",
"required": true,
"type": "string",
"description": "Name of the account"
}, {
"name": "accountType",
"in": "query",
"required": true,
"type": "string",
"description": "The type of account"
}],
"responses": {
"201": {
"description": "The response when the account does not already exist and we can create one",
"schema": {
"$ref": "#/definitions/accountDetails"
}
},
"409": {
"description": "The response when the account already exists and we cannot create one",
"schema": {
"$ref": "#/definitions/accountDetails"
}
},
"400": {
"description": "Error response if the account name parameter is less than minimum characters",
"schema": {
"$ref": "#/definitions/errorModel"
}
},
"404": {
"description": "Error response if the account is not supported by service or account is not found",
"schema": {
"$ref": "#/definitions/errorModel"
}
}
}
},
"put": {
"operationId": "updateAccount",
"summary": "Updates an account",
"description": "Updates the account with specified name",
"consumes": ["text/plain"],
"produces": ["application/json"],
"parameters": [{
"name": "accountName",
"in": "path",
"required": true,
"type": "string",
"description": "Name of the account"
}, {
"name": "accountType",
"in": "query",
"required": true,
"type": "string",
"description": "The type of account"
}],
"responses": {
"200": {
"description": "The response when system finds an account with given name",
"schema": {
"$ref": "#/definitions/accountDetails"
}
},
"400": {
"description": "Error response if the account name parameter is less than minimum characters",
"schema": {
"$ref": "#/definitions/errorModel"
}
},
"404": {
"description": "Error response if the account is not supported by service or account is not found",
"schema": {
"$ref": "#/definitions/errorModel"
}
}
}
}
}
},
"definitions": {
"accountDetails": {
"required": ["id", "name", "type", "availableBal"],
"properties": {
"id": {
"type": "string",
"description": "id"
},
"name": {
"type": "string",
"description": "name"
},
"type": {
"type": "string",
"description": "type"
},
"availableBal": {
"type": "string",
"description": "availableBal"
}
}
},
"errorModel": {
"required": ["errorCode", "errorMessage"],
"properties": {
"errorCode": {
"type": "string",
"description": "A service-specific error code."
},
"errorMessage": {
"type": "string",
"description": "A service-specific error code."
}
}
}
}
}
from dataclasses import dataclass
@dataclass
class Book_list:
name: str
perunit_cost: float
quantity_available: int = 0
# function to calculate total cost
def total_cost(self) -> float:
return self.perunit_cost * self.quantity_available
book = Book_list("Introduction to programming.", 300, 3)
x = book.total_cost()
# print the total cost
# of the book
print(x)
# print book details
print(book)
# 900
Book_list(name='Python programming.',
perunit_cost=200,
quantity_available=3)
Comments