Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Other Programming › Java › Need urgent help!

Need urgent help!

Posts 1–5 of 5 · Page 1 of 1
yair
yair
Need urgent help!
so i have an assignment due in the next 19 hours and im pretty basic with java...here is my assingment

Create any class that you want that represents any real world object. It must have the following

At least 3 instance variables (each one must be a different data type) (1pt)
getter methods (accessor) for each instance variable (1pt)
setter methods (mutator) for each instance variable (1pt)
a display() method that prints out all the values of your instance variables (1pt)
Create another java file called Demo.java , and in the main method create 2 objects of your class. Set the all the data of each object using your setter methods, and call the display() method for each object (1pt)

i have chosen to do a bag of chips, so my 3 instances would be height,length and area...im not too comfortable with getters and setters
anything helps...thank you for your time in advance
#1 · 14y ago
Takari
Takari
I believe that getter and setter are just inputs from a keyboard .

I always used the Keyboard Class or the scan method .
For the Keyboard Class you only need to do a new file and I'm sure you can find the whole code on the internet .

Than you just do something like this:
Code:
example = Keyboard.readInt () ;
#2 · 14y ago
Erinador
Erinador
All of this is at the top of my head. Do ask me if you think you have found a mistake.

Code:
// CLASS 1
public class BagOfChips 
{
        private double height; // 0.00
        private int width; // 0
        private String type; //Salty, paprika, ...

        //display() displays all the values of the variables in the console
        public void display()
        {
                System.out.println("Details of BagOfChips:");
                System.out.printf("Height variable value: %.2f\n", this.height);
                System.out.printf("Width variable value: %d\n", this.width);
                System.out.printf("Type variable value: %s\n", this.type);
        }

        //getter height
        public double getHeight()
        {
                return this.height;
        }

        //setter height
        public void setHeight(double height)
        {
                this.height = height;
        }

        //getter width
        public int getWidth()
        {
                return this.width;
        }

        //setter width
        public void setWidth(int width)
        {
                this.width = width;
        }

        //getter type
        public String getType()
        {
                return this.type;
        }
        
        //setter type
        public void setType(String type)
        {
                this.type = type;
        }

}

//CLASS 2

public class Demo
{
        public static void main(String[] args)
        {
                BagOfChips bagOfChip1 = new BagOfChips();
                BagOfChips bagOfChip2 = new BagOfChips();
                
                //set values of the first BagOfChips
                bagOfChip1.setType("Salty");
                bagOfChip1.setHeight(5.00); //.00 isn't needed, but it's just to show you it can take values beyond the '.'
                bagOfChip1.setWidth(3); //This can't take values beyond the .00 if you would do 3.99 it would just be 3

                //Set the values of the second bag of chips
                bagOfChip2.setType("Paprika");
                bagOfChip2.setHeight(10.00); 
                bagOfChip2.setWidth(6);
                
                bagOfChip1.display();
                bagOfChip2.display();                
                

        }
}
#3 · 14y ago
NextGen1
NextGen1
Quote Originally Posted by Erinador View Post
All of this is at the top of my head. Do ask me if you think you have found a mistake.

Code:
// CLASS 1
public class BagOfChips 
{
        private double height; // 0.00
        private int width; // 0
        private String type; //Salty, paprika, ...

        //display() displays all the values of the variables in the console
        public void display()
        {
                System.out.println("Details of BagOfChips:");
                System.out.printf("Height variable value: %.2f\n", this.height);
                System.out.printf("Width variable value: %d\n", this.width);
                System.out.printf("Type variable value: %s\n", this.type);
        }

        //getter height
        public double getHeight()
        {
                return this.height;
        }

        //setter height
        public void setHeight(double height)
        {
                this.height = height;
        }

        //getter width
        public int getWidth()
        {
                return this.width;
        }

        //setter width
        public void setWidth(int width)
        {
                this.width = width;
        }

        //getter type
        public String getType()
        {
                return this.type;
        }
        
        //setter type
        public void setType(String type)
        {
                this.type = type;
        }

}

//CLASS 2

public class Demo
{
        public static void main(String[] args)
        {
                BagOfChips bagOfChip1 = new BagOfChips();
                BagOfChips bagOfChip2 = new BagOfChips();
                
                //set values of the first BagOfChips
                bagOfChip1.setType("Salty");
                bagOfChip1.setHeight(5.00); //.00 isn't needed, but it's just to show you it can take values beyond the '.'
                bagOfChip1.setWidth(3); //This can't take values beyond the .00 if you would do 3.99 it would just be 3

                //Set the values of the second bag of chips
                bagOfChip2.setType("Paprika");
                bagOfChip2.setHeight(10.00); 
                bagOfChip2.setWidth(6);
                
                bagOfChip1.display();
                bagOfChip2.display();                
                

        }
}
, Either YOU uploaded this source or it's not off the top of your head as you claim.
#4 · 14y ago
Erinador
Erinador
I swear to god, it's all typed in the Quick reply box. (Used multiple spaces as tabs)

I'm a college student so this stuff is easy peasy lemon squeezy.

I guess I could take it as a complement. =D
#5 · edited 14y ago · 14y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • C++ programming HW NEED TO FINISH TONIGHT AND EMAIL TO MY TEACHER URGENT HELP NEEDEDBy Orteez in Suggestions, Requests & General Help
    3Last post 15y ago
  • NEED YOUR HELP URGENTLY!By G.Andrew in General
    22Last post 15y ago
  • Help needed urgently!By privatejk1 in WarRock Help
    8Last post 15y ago
  • URGENT HELP NEEDEDBy /b/oss in General
    18Last post 14y ago

Tags for this Thread

None