Thinking Boi
0
Q:

java method overriding

Method overloading is providing two separate methods in a class with the same name but different arguments, while the method return type may or may not be different, which allows us to reuse the same method name.

Method overriding means defining a method in a child class that is already defined in the parent class with the same method signature, same name, arguments, and return type
3
// Base Class 
class Parent { 
    void show(){ 
        System.out.println("Parent's show()"); 
    } 
} 
// Inherited Class 
class Child extends Parent { 
    // This method overrides show() of Parent Class
    @Override
    void show(){ 
        System.out.println("Child's show()"); 
    } 
}
// Main class 
class Main { 
    public static void main(String[] args){ 
        Parent obj = new Child(); 
		// Calling Child Class Method
        obj.show(); 
    } 
}
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