Question
Please make the java files that follow the below steps. PLEASE as soon as possible. ------------------------------------- Card.java ------------------------------------- import java.util.Random; public class Card implements Comparable
Please make the java files that follow the below steps. PLEASE as soon as possible.
-------------------------------------
Card.java
-------------------------------------
import java.util.Random;
public class Card implements Comparable
public Card(int power, int toughness) { this.power = power; this.toughness = toughness; calculateCost(); }
public int getPower() { return power; }
public int getToughness() { return toughness; }
private void calculateCost() { cost = (int)(Math.sqrt(1.5*power + 0.9*toughness)); } public int getCost() { return cost; } public void weaken() { power = (int) (power - power*0.1 ); toughness = (int) (toughness - toughness*0.1 ); calculateCost(); } public void boost() { power = (int) (power + power*0.1 ); toughness = (int) (toughness + toughness*0.1 ); calculateCost(); } @Override public boolean equals(Object obj) { if(obj instanceof Card) { Card card = (Card)obj; if(card.getCost() == this.cost && card.getPower() == this.power && card.getToughness() == this.toughness) { return true; } else return false; } else return false; } @Override public String toString() { return "[" + power + "/" + toughness + "]"; }
@Override public int compareTo(Card o) { if(o == null) return -1; if(this.equals(o)) return 0; else if(cost == o.getCost()) { if(power == o.getPower()) return 0; else if(power o.getCost()) return 1; else return -1; }
}
CS145-PROGRAMMING ASSIGNMENT #8 MORE WITH CARDS OVERVIEW This program focuses on heaps and using the GUI INSTRUCTIONS Turn in Card.java, CardHeap.java and your main file. You are allowed to reuse your Card.java from a prior assignment with any necessary changes that you want to add IMPLEMENTATION DETAILS: You will reuse your Card.java file and you will write the GUI form and the CardHeap.java files to implement the necessary behavior THE PROGRAM In this assignment, you will implement a simple GUI program that will randomly add/remove cards that are the same as the ones we used in assignment #7 to a heap (Note that we will be ignoring the premium cards, although they should still work.). Your program should look like the following At the beginning CS 145 GUI Assignment-Your Name Here Last Removed Add Cloar CS145-PROGRAMMING ASSIGNMENT #8 MORE WITH CARDS OVERVIEW This program focuses on heaps and using the GUI INSTRUCTIONS Turn in Card.java, CardHeap.java and your main file. You are allowed to reuse your Card.java from a prior assignment with any necessary changes that you want to add IMPLEMENTATION DETAILS: You will reuse your Card.java file and you will write the GUI form and the CardHeap.java files to implement the necessary behavior THE PROGRAM In this assignment, you will implement a simple GUI program that will randomly add/remove cards that are the same as the ones we used in assignment #7 to a heap (Note that we will be ignoring the premium cards, although they should still work.). Your program should look like the following At the beginning CS 145 GUI Assignment-Your Name Here Last Removed Add CloarStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started