Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:55:47+00:00 2026-06-15T05:55:47+00:00

Hi everyone I am doing my homework and I got stuck so I need

  • 0

Hi everyone I am doing my homework and I got stuck so I need a bit of feedback.

I have a abstract class Gear and enum type Info in one package, then I have InfoTest which uses the assert and junit test to test the correctness of the Gear and the Info.

Problem is in the InfoTest. I have Info g = some Value; and then g.getWeight() which method is in the Gear class and I can’t access the getWeight() method from InfoTest through Info object.

So I was wondering whether there is a way to access getWeight() with an Info object from InfoTest or my teacher has made a mistake. Thaks.

OKKKKKKKKKKK here is some code sample.

public abstract class Gear {

/**
 * weight stores the weight of the item in kg
 */
protected int weight;

/**
 * code store the code for the item (bedding, food, medical or sanitary, but it is better to use array.
 */
protected char code;

/**getWeight gets the weight of the item.
 * 
 * @return weight
 */        
public int getWeight() {
    return weight;
}

/**setWeight sets the weight for the item
 * 
 * @param weight 
 */
public void setWeight(int weight) {
    this.weight = weight;
}

/**getCode() gets the code of the item.
 * 
 * @return code
 */
public char getCode() {
    return code;
}

/**setCode sets the code of the item.
 * 
 * @param code 
 */
public void setCode(char code) {
    this.code = code;
} }

public enum Info {

/**
 * BLANKETS represent the blankets.
 */
BLANKETS,

/**
 * PILLOWS represent the pillows 
 */
PILLOWS,

/**
 * FOOD represent the food
 */
FOOD,

/**
 * MEDKIT represent the medical kit.
 */
MEDKIT,

/**
 * OXYGEN represent the oxygen 
 */
OXYGEN,

/**
 * NAPKINS represent the napkins.
 */
NAPKINS,

/**
 * SICKNESSBAG represent the sickness bags.
 */
SICKNESSBAG
 }
> public class InfoTest {  
      /**
>      * Test of getWeight() method, of class Info. 
>      */
>     @Test
>     public void testGetWeight() {
>       System.out.print("\tChecking weights in Info");
>       Info g = Info.BLANKETS;
>       final int expectedValue1 = 2;
>       assertEquals(expectedValue1, g.getWeight()); }
> 
> }
  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:55:49+00:00Added an answer on June 15, 2026 at 5:55 am

    The problem is that Info is an enumerated class, it does not have access to the Gear class at the moment. Its very difficult to work out exactly what the scope of your homework is.

    Something like this…
    Firstly make another class which extends your abstract class (something like SubGear)

    public SubGear extends Gear
    

    In this class have a constructor which takes in the Info object and also populates the fields from the Gear class like this:

    public SubGear (Info info, int weight, char code){
        this.code = code;
        this.weight= weight;
        this.info = info
    }
    
    public void setInfo(Info info){
         this.info = info;
    }
    
    public Info getInfo(){
        return info;
    }
    

    Then in your test create a new SubGear object in order to access the getWeight as you require

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a homework assignment where I have a base class Package, and two
Good evening everyone, I have a quick question on a homework assignment my class
Hey everyone, great community you got here. I'm an Electrical Engineer doing some programming
I have seen a couple threads about what everyone was doing now a days
Hi everyone I am doing homework and I don't understand one part of it.I
Hi everyone im doing a little assignment in python and I need to do
Hope everyone is doing well. I have the following output... +---------+--------------+--------------+-----------+---------+----------+ | ord_num |
Helo everyone. I have a class MyClass and a function escape () that can
EveryOne I am doing xml parsing like This public class XMLHandler extends DefaultHandler{ //
Hey everyone I have a script problem once again. I'm doing a jQuery show/hide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.