#can someone help me start on this problem? i don't know how to do

1 messages · Page 1 of 1 (latest)

rancid bison
#

Write ComputerTester class containing It should have a main method in it. Inside the main method:
o Create a Computer object named myLaptop using “Dell” and 1,000,000.
o Use the setter method to change the instance variable dualCore to true;
o Display the maker, size, speed and dualCore for myLaptop.
o Create a Computer object named myTablet using “Surface” and 150,000
o Display the maker, size, speed and dualCore for myTablet.

pliant hullBOT
#

<@&987246399047479336> please have a look, thanks.

pliant hullBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

Certainly! Here's how you can start on the problem:

  1. First, create a new Java class called "ComputerTester". This class will contain the main method.
public class ComputerTester {
    public static void main(String[] args) {
        // Your code goes here
    }
}
  1. Inside the main method, create a new object of the "Computer" class and name it "myLaptop" (or any other name you prefer).
public static void main(String[] args) {
    Computer myLaptop = new Computer();
}
  1. Now you have created a "Computer" object named "myLaptop". However, since we don't have the definition of the "Computer" class yet, you will need to create it separately.
public class Computer {
    // Your code for the Computer class goes here
}

At this point, you have created both the "ComputerTester" and "Computer" classes. You can continue working on defining the properties and methods of the "Computer" class based on your requirements.

Let me know if you need any further assistance!

lost vapor
#

Do you already have a Computer class?

rancid bison
#

i don't quite understand what objects are

lost vapor
rancid bison
#

yes

lost vapor
#

well object is an instance of a class

#

idk how to put explain it better, but if class was a design then when you make something based on that design that's object. It will have all the same properties.

rancid bison
#

to my understanding, class is like a category and so the objects i make are based into that category?

lost vapor
#

idk about category, some folks call it blueprint. But more or less yes, when you do new ClassNameHere() you get an object aka new instance of that class.

rancid bison
#

ok i believe i get it

lost vapor
#
class Person{
    String gender;
    String name;
    int age;
    
    public Person(String gender, String name, int age){
        // initialize
    }
}```
#

for example, this is a Person class. Each object/instance of Person will have certain properties gender, name and age.

rancid bison
#

okay, how does this look for my code so far?

    public class Computer {
        String Dell;
        int 1000000;
    }
    public static void main(String [] args) {
        Computer myLaptop = new Computer("Dell", 1000000);
        
    }
}
pliant hullBOT
lost vapor
#

You also forgot to add the constructor for your Computer class

rancid bison
#

okay i'm working on it

#

my constructor would be something like this.computer = computer right?

lost vapor
rancid bison
#

i'm a bit lost

lost vapor
# rancid bison i'm a bit lost

first thing i already mentioned, either make a new file for Computer class or move it outside of ComputerTester class( after the bracket on line 18)

#

Once you do that, look at the constructors link i shared. Based on that make a new constructor for your Computer class.

rancid bison
#

ok i moved it out

#

i will work on 2nd part now and update

lost vapor
#

yes take your time, you should understand why we use constructor or what does it mean.

rancid bison
#

this is my constructor

#

i really don't know what the 1000000 is supposed to be for the assignment question but I assume it's speed

lost vapor
rancid bison
rancid bison
#

i'm sorry if i'm so lost. i'm in a fundamentals course and my friend just told me this question is supposed to be an intermediate course question

#

bc this is object oriented programming

zinc haven
#

In reality you should make a new class called Computer and this is your model you can put getters and getters and a constructor in here for the variables you want to set and then in your main class you can ether build the object with getters and setters or call the constructor and pass in the variables

zinc haven
# rancid bison

This is close the constructor needs to be inside the Computer Class as if its not makes no sense

restive pond
rancid bison
#

i think i was able to get some more progress. i will update the code when i get home

rancid bison
#
    private String maker;
    private int speed;
    private int size;
    private boolean dualCore;
    public void setMaker(String maker) {
        this.maker = maker;
    }
    public void setSpeed(int speed) {
        this.speed = speed;
    }    
    public void setSize (int size) {
        this.size = size;
    }
    public void setDualCore(boolean dualCore) {
        this.dualCore = dualCore;
    }
    public String getMaker() {
        return maker;
    }
    public int getSpeed() {
        return speed;
    }   
    public int getSize() {
        return size;
    }
    public boolean isDualCore() {
        return dualCore;
    }
}```
pliant hullBOT
# rancid bison ```class Computer { private String maker; private int speed; private...

Detected code, here are some useful tools:

Formatted code
class Computer {
  private String maker;
  private int speed;
  private int size;
  private boolean dualCore;
  public void setMaker(String maker) {
    this .maker = maker;
  }
  public void setSpeed(int speed) {
    this .speed = speed;
  }
  public void setSize(int size) {
    this .size = size;
  }
  public void setDualCore(boolean dualCore) {
    this .dualCore = dualCore;
  }
  public String getMaker() {
    return maker;
  }
  public int getSpeed() {
    return speed;
  }
  public int getSize() {
    return size;
  }
  public boolean isDualCore() {
    return dualCore;
  }
}
fossil hollow
rancid bison
lost vapor