Question

In: Computer Science

1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class...

1. PHP OOP

Create a complete PHP enabled website that defines and uses a PineApple class in PHP. The class has following members.

Properties

$color: string type

$taste: string type

$weight: number type

Standard constructor, with 3 parameters

Member functions

eat(): no return, no parameter, print a short paragraph in English to describe

how to eat a pineapple.

grow(): no return, no parameter, print a short paragraph in English to describe how to grow a pineapple plant.

display(): no return, no parameter, print the name and current value of every property of this class.

In the primary PHP script, create two objects from the PineApple class. Then call every member function form each object in an appropriate manner.

2. JavaScript OOP

Write a complete webpage with embedded JavaScript code that defines a bunny object that is made of following properties and methods.

Property color: string type

Property earLength: number type

Property furType: string type

Method toPrint(): print out the name and value of every property of this current object

Method run(): print out the procedure that describes how this bunny swims.

In details, do the following

Create a bunny object using object literal.

Define the constructor function of bunny and create another bunny object using this constructor and the new keyword.

Read three property values from the keyboard with proper prompt for every object created above.

For each object, call its every method.

Solutions

Expert Solution

Please try to divide multiple questions to seperate individual questions. Here is the code for the first one. PHP:
------

<?php

class PineApple{
   var $color;
   var $taste;
   var $weight;

   function __construct($c, $t, $w){
       $this->color = $c;
       $this->taste = $t;
       $this->weight = $w;
   }

   function eat(){
       echo "<br><br>Cut PineApple into pieces using a knife or by hand if you like. Remember to remove outer shell before otherwise it case cause some serious damage to stomache. Then just eat it bro.";
   }

   function grow(){
       echo "<br><br>Find PineApple seeds somewhere lying around, I don't know man where you can find them just buy it on amazon. Then get some water, some soil, some sunlight and mix them up together. Bamm! you got PineApple.";
   }

   function display(){
       echo "<br>Color:".$this->color;
       echo "<br>Taste:".$this->taste;
       echo "<br>Weight:".$this->weight;
   }
}


?>
<!DOCTYPE html>
<html>
<head>
   <title>PineApple</title>
</head>
<body>
<?php
   $A = new PineApple("blue", "salty", 23);
   $A->grow();
   $A->eat();
   $A->display();
   echo "<hr>";
   $B = new PineApple("yellow", "sweet", 11);
   $B->grow();
   $B->eat();
   $B->display();
?>
  
</body>
</html>

-------

------

Hastebin link in case code lose formatting: http://www.hastebin.com/tefahinato.xml


Related Solutions

Write a OOP class called BookList that uses a Book class and allows multiple books to...
Write a OOP class called BookList that uses a Book class and allows multiple books to be entered into a BookList object. Include normally useful methods and boolean addBook(Book b), Book searchBook(String title, String author). addBook returns true if b is successfully added to the list. searchBook returns a book matching either the title or author from the current list. You do not need to write Book (assume there are suitable constructors and methods) or any test code (main). You...
Create a java program that: - Has a class that defines an exception -Have that exception...
Create a java program that: - Has a class that defines an exception -Have that exception throw(n) in one method, and be caught and handled in another one. -Has a program that always continues even if incorrect data is entered by the user -has a minimum of 2 classes in it
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)    3. Assign your name as a string value into the variable labeled myName (Unit Objective 2)    4. Assign 53870 numeric value into the variable named randomNumber (Unit Objective 2) 5. ssign the name of the web browser and operating system of the...
with PHP Create a class called Invoice that a hardware store might use to represent an...
with PHP Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables — a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method...
Using PHP, Create a form that uses the method POST to send the information. The form...
Using PHP, Create a form that uses the method POST to send the information. The form should capture the distance the package needs to travel with the one field for the distance in miles. All fields should have the REQUIRED attribute. The form should have a submit button and reset button. The form should look nice. All the labels should line up horizontally and all the INPUTS/SELECT should line up horizontally.
With PHP Create a class called Account that a bank might use to represent customers' bank...
With PHP Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member of type int to represent the account balance. Your class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the...
with PHP Create a class called Employee that includes three instance variables—a first name (type String),...
with PHP Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary int). Provide a constructor that initializes the three instance data member. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its 0. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary....
Create a PHP class named "User" with the following private fields: name, birthdate in yyyy/mm/dd format,...
Create a PHP class named "User" with the following private fields: name, birthdate in yyyy/mm/dd format, age, and department. In the class, include getter and setter methods to get and set the values of those variables. Author a data entry webform using HTML text input boxes and a submit button. When the user clicks on the submit button, a "User" class is instantiated and the new User object's fields are populated. The HTML input boxes correspond to the field in...
Java the goal is to create a list class that uses an array to implement the...
Java the goal is to create a list class that uses an array to implement the interface below. I'm having trouble figuring out the remove(T element) and set(int index, T element). I haven't added any custom methods other than a simple expand method that doubles the size by 2. I would prefer it if you did not use any other custom methods. Please use Java Generics, Thank you. import java.util.*; /** * Interface for an Iterable, Indexed, Unsorted List ADT....
JAVA PROJECT Step 1: Create an application named YourInitials_Project 3 that uses a class to convert...
JAVA PROJECT Step 1: Create an application named YourInitials_Project 3 that uses a class to convert number grades to letter grades and another class for data validation. Make comments including your name, date, and project name as well as appropriate comments throughout your application that include the step number. Step 2: Create code to print Titles Step 3: Create a variable to hold user’s choice. Remember that all variables must begin with your initials and should be descriptive. Step 4:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT