Dan
4
Q:

override java

// A Simple Java program to demonstrate 
// method overriding in java 
  
// Base Class 
class Parent { 
    void show() 
    { 
        System.out.println("Parent's show()"); 
    } 
} 
  
// Inherited class 
class Child extends Parent { 
    // This method overrides show() of Parent 
    @Override
    void show() 
    { 
        System.out.println("Child's show()"); 
    } 
} 
// Driver class 
class Main { 
    public static void main(String[] args) 
    { 
        // If a Parent type reference refers 
        // to a Parent object, then Parent's 
        // show is called 
        Parent obj1 = new Parent(); 
        obj1.show(); 
  
        // If a Parent type reference refers 
        // to a Child object Child's show() 
        // is called. This is called RUN TIME 
        // POLYMORPHISM. 
        Parent obj2 = new Child(); 
        obj2.show(); 
    } 
} 
5
class Animal {
   public void move() {
      System.out.println("Animals can move");
   }
}

class Dog extends Animal {
   public void move() {
      System.out.println("Dogs can walk and run");
   }
}

public class TestDog {

   public static void main(String args[]) {
      Animal a = new Animal();   // Animal reference and object
      Animal b = new Dog();   // Animal reference but Dog object

      a.move();   // runs the method in Animal class
      b.move();   // runs the method in Dog class
   }
}
1
using method-override in your index.js
1. npm install method-override --save
2. var methodOverride = require("method-override");
3. app.use(methodOverride("_method"));
//'_method' is what methodOverride will look for
method override in your UPDATE route: 
* <form action = "/campgrounds/<%=campground._id%>/edit?_method=PUT" 
	method = "POST">
and EDIT routes: 
0
public static void main(String[] args) {
  int menuOption;
  int foodItem = 0;
  input = new Scanner(System.in);
  double runningTotal=0;
  do{
    menu();
    menuOption = input.nextInt();
    switch(menuOption){
      case 1:
        foodItem = 1;
        runningTotal += itemPrice(foodItem);
        break;
      case 2:
        foodItem = 2;
        runningTotal += itemPrice(foodItem);
        break;
      case 3:
        foodItem = 3;
        runningTotal += itemPrice(foodItem);
        break;
      case 4:
        done(runningTotal);
        break;
      default:
        System.out.println("Invalid option.");
    }
  } while(ordering);
  System.out.println("Total amount: " + runningTotal);
}
-1

New to Communities?

Join the community