
Concept explainers
CREATE ANOTHER CLASS FOR TEAM
The CODE FOR POKEMON:
package com.company;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util .*;
public class Pokemaon implements Comparable, Serializable, Fightable {
String name;
int level;
int health;
int attack;
String type;
//2 Constructors - 1 Default, 1 sets all variables
public Pokemaon(String name, int level, int health, int attack, String type) {
super();
this.name = name;
this.level = level;
this.health = health;
this.attack = attack;
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getHealth() {
return health;
}
public void setHealth(int health) {
this.health = health;
}
public int getAttack() {
return attack;
}
public void setAttack(int attack) {
this.attack = attack;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "Pokemaon [name=" + name + ", level=" + level + ", health=" + health + ", attack=" + attack + ", type="
+ type + "]";
}
@Override
public int compareTo(Object o) {
System.out.println("compareTo() method......");
return 0;
}
@Override
public void dealDamage() {
System.out.println("dealDamage() method......");
}
public static void main(String[] args) throws IOException, ClassNotFoundException {
Scanner sc1 = new Scanner(System.in);
Scanner sc2 = new Scanner(System.in);
System.out.println("Please enter the name..");
String name = sc1.nextLine();
System.out.println("Please enter the level..");
int lev = sc2.nextInt();
System.out.println("Please enter the health..");
int hel = sc2.nextInt();
System.out.println("Please enter the type..");
String type = sc1.nextLine();
System.out.println("Please enter the attack..");
int att = sc2.nextInt();
Pokemaon a = new Pokemaon(name, lev, hel, att, type);
FileOutputStream fos = new FileOutputStream("C:\\Users\\HP\\OneDrive\\Desktop\\xyz.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(a);
System.out.println("Data read successfully....");
}
}
.


Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images

- Circle Class (This is in JAVA) /** * Defines a basic shape with just area * * @author Jo Belle * @version 0.2 (10/05/2020) */ public class Shape{ private double area; public Shape(){ area = 0.0; } public Shape( double a ){ this.area = a; } public void setArea( double a ){ area = a; } public double getArea(){ return area; } public String toString(){ return "Shape:\n\tarea: " + area; } }/** * Create a simple Circle object * * @author Jo Belle * @version 0.2 (10/12/2020) */ public class ShapeDriver{ public static void main( String[] args ){ Circle cir = new Circle( ); cir.setRadius( 5.0 ); System.out.println( cir.toString() ); } } Given the code above, write a Circle class (and save it in a file named Circle.java) that inherits from the Shape class. Include in your Circle class, a single private field double radius. Also include a method void setRadius(double r) (which also sets area) and a method double getRadius() (which also returns the current radius). Change the accessibility…arrow_forwardWrite a Java codearrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…arrow_forward
- 1 Java onlyarrow_forwardpublic class OfferedCourse extends Course { // TODO: Declare private fields // TODO: Define mutator methods - // setInstructorName(), setLocation(), setClassTime() // TODO: Define accessor methods - // getInstructorName(), getLocation(), getClassTime() } import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, location, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); location = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle);…arrow_forwardJavaarrow_forward
- Java code about Enrollment System Please help. So this is the code: import java.util.Scanner; class User { String username; String password; String role; public User(String username, String password, String role) { this.username = username; this.password = password; this.role = role; } public String getUsername() { return username; } public String getPassword() { return password; } public String getRole() { return role; } } class Course { String courseCode; String courseTitle; int units; public Course(String courseCode, String courseTitle, int units) { this.courseCode = courseCode; this.courseTitle = courseTitle; this.units = units; } public String getCourseCode() { return courseCode; } public String getCourseTitle() { return courseTitle; } public int getUnits() { return units; } } class EnrollmentSystem { User[] users = new User[10]; int userCount = 0; Course[] courses = new Course[10]; int courseCount = 0; Scanner sc = new Scanner(System.in); public void…arrow_forwardclass IndexItem { public: virtual int count() = 0; virtual void display()= 0; };class Book : public IndexItem { private: string title; string author; public: Book(string title, string author): title(title), author(author){} virtual int count(){ return 1; } virtual void display(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Category: public IndexItem { private: /* fill in the private member variables for the Category class below */ ? int count; public: Category(string name, string code): name(name), code(code){} /* Implement the count function below. Consider the use of the function as depicted in main() */ ? /* Implement the add function which fills the category with contents below. Consider the use of the function as depicted in main() */ ? virtualvoiddisplay(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };arrow_forwardJava Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





