Java - How to define classes

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java - How to define classes

  1. #1
    Join Date
    Sep 2005

    Java - How to define classes

    I was wondering if someone could let me know if my basic template for making my own class(es) is right so far. It's an assignment for school so I was provided with the but I have to create my own class and use the Math class to compute shipping and total price. I'm not sure if the code will display below in the attachment but the file is .zip. (Ignore everything in comments, I will get back to that once I figure out the basic layout on how to do classes.)

    I'm pretty sure I'm going to need numLgBoxes, numMedBoxes, numSmBoxes, and totalPrice classes to do this.
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2005
    the Netherlands
    Here's a start:
    class MyJava {
        private int noBags = 0;
        private int largeBoxes = 0;
        private int mediumBoxes = 0;
        private int smallBoxes = 0;
        private int totPrice = 0;
        public MyJava(int n) {
            this.noBags = n;
        public int price() {
            // return something
        public int numLgBoxes() {
            // return something
        public int numMedBoxes() {
            // return something
        public int numSmBoxes() {
            // return something
        public int totalPrice() {
            // return something
    Don't use the same variable- and method names. So if the method is called numLgBoxes don't use the same name for a variable.

Similar Threads

  1. java classes in windows and linux
    By DaveMere in forum Java
    Replies: 2
    Last Post: 08-09-2005, 02:11 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 07:46 AM
  3. VB/C Array parameters
    By Gastao Woelfert in forum VB Classic
    Replies: 2
    Last Post: 09-01-2000, 12:36 PM
  4. VB/C Array parameters
    By Gastao Woelfert in forum VB Classic
    Replies: 0
    Last Post: 09-01-2000, 09:59 AM
  5. Adding Columns to comboboxes through API
    By Lori Taylor in forum VB Classic
    Replies: 20
    Last Post: 06-14-2000, 12:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center