Answer the question
In order to leave comments, you need to log in
How to make code in MVC style?
I have a study assignment. The question arises how to do all this in the MVC architectural style? Below I have also indicated not implemented classes and interface. I can’t understand what and how to implement certain classes, what and where to call, and so on. Description:
Knight. Determine the hierarchy of the knight's ammunition. Operations with a knight:
Display the characteristics of the knight
Display a list of the knight's ammunition
Equip the knight, which should be reflected in his characteristics (for example, weight, attack power, etc.)
Sorting the ammunition based on one of the parameters
Find the elements of ammunition that correspond to the specified range of parameters.
I/O Example
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
2
Sword{damage=10, weight=20, cost=30}
Helmet{protection=30, weight=10, cost=20}
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
3
What kind of ammunition do you want to equip?
1. Sword
2. Helmet
Choose option:
1
Input sword weight:
100
Input sword cost:
2
Input sword damage:
30
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
2
Sword{damage=10, weight=20, cost=30}
Helmet{protection=30, weight=10, cost=20}
Sword{damage=30, weight=100, cost=2}
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
1
Ammunition cost: 52
Ammunition weight: 130
Ammunition damage: 40
Ammunition protection: 30
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
4
Choose sort type:
1. Cost
2. Weight
Choose option:
2
Helmet{protection=30, weight=10, cost=20}
Sword{damage=10, weight=20, cost=30}
Sword{damage=30, weight=100, cost=2}
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
5
Choose search field:
1. Cost
2. Weight
Choose option:
1
Input minimum cost:
0
Input maximum cost:
5
Sword{damage=30, weight=100, cost=2}
Main menu:
1. Print knight stats
2. Show ammunition
3. Equip ammunition
4. Sort ammunition
5. Search ammunition
6. Exit
Choose option:
6
Bye!
public class KnightApplication {
public static void main(String[] args) {
KnightApplication application = new KnightApplication();
application.start();
}
private void start() {
throw new UnsupportedOperationException("You need to implement this method");
}
}
public class Knight {
private Ammunition[] ammunition;
public Ammunition[] getAmmunition() {
throw new UnsupportedOperationException("You need to implement this method");
}
/**
* Add new ammunition element to knight
* @param element that should be equipped to the knight
*/
public void equip(Ammunition element) {
throw new UnsupportedOperationException("You need to implement this method");
}
public int calculateAmmunitionWeight() {
throw new UnsupportedOperationException("You need to implement this method");
}
public int calculateAmmunitionCost() {
throw new UnsupportedOperationException("You need to implement this method");
}
public int calculateAmmunitionDamage() {
throw new UnsupportedOperationException("You need to implement this method");
}
public int calculateAmmunitionProtection() {
throw new UnsupportedOperationException("You need to implement this method");
}
}
public class KnightGenerator {
/**
* Use it to quickly generate knight
* @return knight
*/
public static Knight generateKnight() {
throw new UnsupportedOperationException("You need to implement this method");
}
public interface Ammunition {
int getWeight();
int getCost();
}
public class ConsoleView {
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
public class Knight {
private Ammunition[] ammunition;
Controller
throw new UnsupportedOperationException("You need to implement this method");
Model
View
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question