בית פורומים למתכנתים שבינינו

תרגיל - מחשב

שלום אורח. באפשרותך להתחבר או להירשם
הצג 15 הודעות בעמוד הוסף לדף האישי  דווח למנהל שלח לחבר
נשלח ב-26/12/2013 09:32 לינק ישיר 
תרגיל - מחשב

אני באמצע לפתור תרגיל, יש לי טעות ואין לי מושג איך לתקן אותה. אשאל את השאלה, אשלח את הפתרון שלי ואצביע איפה הטעות.. אשמח לעזרה..

השאלה: צור מחלקה שמגדירה כונן. לכונן יש מהירות בRPM, כמות הזכרון שבכונן (בK) והאות שמייצגת אותו.
הוסף למחלקה קונסטרקטור ופונקציה שמדפיסה בצורה נאה את פרטי הכונן.

צור מחלקה שמגדירה מסך. למסך יש גודל באינצ'ים ורזולוציה (כמה פיקסלים על כמה פיקסלים.
הוסף למחלקה קונסטרקטור ופונקציה שמדפיסה בצורה נאה את פרטי המסך.

צור מחלקה שמגדירה מחשב. למחשב יש שם יצרן, שם מודל, כמות זכרון RAM, עד 5 דיסקים שמחוברים אליו ועד 4 מסכים שמחוברים אליו.
הוסף למחלקה קונסטרקטור ופונקציה שמדפיסה בצורה נאה את פרטי המחשב.

צור מחשב. חבר לו 2 מסכים ו3 דיסקים והדפס את פרטיו בצורה נאה.

יש לדאוג להגדרת רמות גישה מתאימות לאיברים השונים של המחלקות.



דווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-31/12/2013 18:12 לינק ישיר 

אהה. הבנתי עכשיו.

תודה!! אדע להבא.


נשלח מהאנדרואיד שלי




דדווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-31/12/2013 13:13 לינק ישיר 

הדרך הנוחה להכניס קוד, היא כך.

1. לכתוב את כל ההקדמות וההסברים כרגיל.
2. כשמגיעים לקוד, לעבור לעריכת html, ולהכניס את הקוד הבא:


<div style="direction: ltr; text-align: left">
<p>
שומר מקום1
</p>
</div>
 

3. להמשיך לכתוב את מה שאחרי הקוד. במידת הצורך, להוסיף עוד שומרי מקום לקטעי הקוד הנוספים.
4. אחר-כך, להחליף את המילים "שומר מקום1" בקוד המתאים.


תוקן על ידי אור_היום ב- 31/12/2013 13:15:41




דדווח על תוכן פוגעני

מחובר
נשלח ב-31/12/2013 12:23 לינק ישיר 

עכשיו זה מעט טוב יותר:

 


class Program
    {
        static void Main([] args)
        {
            letterOfDrive;

            int driveSpeedInRPM;
            int amountOfMemory;
            input;
            Drive[] drives = null;

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("Please enter the letter of the drive, and press ENTER");
                input = Console.ReadLine();
                letterOfDrive = input[0];
                Console.WriteLine("Please enter the speed of drive in RPM, and press ENTER");
                input = Console.ReadLine();
                driveSpeedInRPM = int.Parse(input);
                Console.WriteLine("Please enter the amount of memory of drive in K, and press ENTER");
                input = Console.ReadLine();
                amountOfMemory = int.Parse(input);
                drives[i] = new Drive(driveSpeedInRPM, amountOfMemory, letterOfDrive);
            }

            int size;
            int resolutionX;
            int resolutionY;
            Monitor[] monitors = null;

            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("Please enter the size of the monitor in inch, and press ENTER");
                input = Console.ReadLine();
                size = int.Parse(input);
                Console.WriteLine("Please enter the resolution X of monitor, and press ENTER");
                input = Console.ReadLine();
                resolutionX = int.Parse(input);
                Console.WriteLine("Please enter the resolution Y of monitor, and press ENTER");
                input = Console.ReadLine();
                resolutionY = int.Parse(input);
                monitors[i] = new Monitor(size, resolutionX, resolutionY);
            }

            manufacturerName;
            modelName;
            int anountMemoryInRAM;
            Console.WriteLine("Please enter the name of manufacturer of the computer, and press ENTER");
            manufacturerName = Console.ReadLine();
            Console.WriteLine("Please enter the model of the computer, and press ENTER");
            modelName = Console.ReadLine();
            Console.WriteLine("Please enter the amount of memory in RAM of the computer, and press ENTER");
            input = Console.ReadLine();
            anountMemoryInRAM = int.Parse(input);
            //Computer computer;
            //computer = new Computer();
        }
    }

    class Drive
    {
        public int driveSpeedInRPM;
        public int amountOfMemory;
        public letterOfDrive;
        public Drive(int driveSpeedInRPM, int amountOfMemory, letterOfDrive)
        {
            this.driveSpeedInRPM = driveSpeedInRPM;
            this.amountOfMemory = amountOfMemory;
            this.letterOfDrive = letterOfDrive;
        }
        public void print()
        {
            Console.WriteLine("the drive: {0}, has {1} drive speed in RPM, and {2} amount of memory", this.letterOfDrive, this.driveSpeedInRPM, this.amountOfMemory);
        }
    }

    class Monitor
    {
        public int size;
        public int resolutionX;
        public int resolutionY;
        public Monitor(int size, int resolutionX, int resolutionY)
        {
            this.size = size;
            this.resolutionX = resolutionX;
            this.resolutionY = resolutionY;
        }
        public void print()
        {
            Console.WriteLine("the monitor has {0} inches, and the resolution is: {1} on {2}", this.size, this.resolutionX, this.resolutionY);
        }
    }

    class Computer
    {
        manufacturerName;
        modelName;
        int anountMemoryInRAM;
        Drive[] drives;
        Monitor[] monitors;
        public Computer( manufacturerName, modelName, int anountMemoryInRAM, Drive drive, Monitor monitor)
        {
            this.manufacturerName = manufacturerName;
            this.modelName = modelName;
            drives = new Drive[5];
            monitors = new Monitor[4];
            connectDrives(drive);
            connectMonitors(monitor);
        }

        public void connectDrives(Drive drive)
        {
            bool flag = true;
            for (int i = 0; i < 5 && flag; i++)
                if (drives[i] == null)
                {
                    drives[i] = drive;
                    flag = false;
                }
        }

        public void connectMonitors(Monitor monitor)
        {
            bool flag = true;
            for (int i = 0; i < 4 && flag; i++)
                if (monitors[i] == null)
                {
                    monitors[i] = monitor;
                    flag = false;
                }
        }

        public void print(Drive[] drives, Monitor[] monitors)
        {
            int count = 0;
            for (int i = 0; i < 5; i++)
            {
                if (drives[i] != null)
                    count++;
            }
            Console.WriteLine("the computer made by {0}, the model is: {1}, his memory is: {2} RAM. conected to him {3} drives:", this.manufacturerName, this.modelName, this.anountMemoryInRAM, count);
            for (int i = 0; i < 5; i++)
                if (drives[i] != null)
                    Console.WriteLine("{0}. {1}, has {2} drive speed in RPM, and {3} amount of memory.", i, drives[i].letterOfDrive, drives[i].driveSpeedInRPM, drives[i].amountOfMemory);
            count = 0;
            for (int i = 0; i < 4; i++)
            {
                if (monitors[i] != null)
                    count++;
            }
            Console.WriteLine("and conected to him {0} monitors:", count);
            for (int i = 0; i < 4; i++)
                if (monitors[i] != null)
                    Console.WriteLine("{0}, he has {1} inches, and the resolution is: {2} on {3}", i, monitors[i].size, monitors[i].resolutionX, monitors[i].resolutionY);
        }
    }





תוקן על ידי אור_היום ב- 31/12/2013 12:26:15




דדווח על תוכן פוגעני

מחובר
נשלח ב-31/12/2013 10:46 לינק ישיר 

הבעיה שכל קוד הHTML לא ברור לי. מלא תוויות שלא ברור לי איפה מתחיל ואיפה נגמר.. אחרת הייתי עושה זאת באמת לבד..



דדווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-31/12/2013 09:54 לינק ישיר 

כך עשיתי זאת:
עברתי לעורך הHTML, וכתבתי את השורה הבאה:
<div style="text-align: left">class abc </div>

אחר-כך אפשר לחזור לעורך הטקסט, ולהחליף את CLASS ABC במה שרוצים.



דדווח על תוכן פוגעני

מחובר
נשלח ב-31/12/2013 09:49 לינק ישיר 

ניסיון:

 

class abc

 



תוקן על ידי אור_היום ב- 31/12/2013 09:51:34




דדווח על תוכן פוגעני

מחובר
נשלח ב-27/12/2013 12:33 לינק ישיר 

מזמן לא נגעתי בHTML ולא זכרתי איך עושים זאת. ראיתי שכן מוגדר ltr ולא רציתי לחרבש את הקוד לשווא..



דדווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-27/12/2013 11:35 לינק ישיר 

כדי להפוך קוד מימין לשמאל, אפשר להשתמש בעורך הhtml , ולהגדיר סטייל.



דדווח על תוכן פוגעני

מחובר
נשלח ב-26/12/2013 12:48 לינק ישיר 

עשיתי את זה.. :)

ב"ה...



דדווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-26/12/2013 09:39 לינק ישיר 

לצערי לא הצלחתי להפוך את זה משמאל לימין שיהיה קריא..

הבעיה שלי כרגע, כשאני רוצה ליצור מחשב - הקונסטרקטור שלי דורש כונן ומסך על מנת להפעיל אותו. לפי הקוד שיצרתי - אין לי אפשרות כיון שאני רוצה רק מחשב אחד ולא כמה אובייקטים, כך שא"א לעשות לולאה עבור כל כונן/מסך..

השאלה אם הפתרון כאן הוא setter ואז את הקוד: 
connectDrives(drive);
connectMonitors(monitor);

אני אעביר לsetter ורק שם יתבצע חיבור כונן/מסך, ולא דרך הקונסטרקטור?



דדווח על תוכן פוגעני

סמל אישי
מנותק
נשלח ב-26/12/2013 09:33 לינק ישיר 

הפתרון שלי:

class Program
    {
        static void Main([] args)
        {
            letterOfDrive;
            int driveSpeedInRPM;
            int amountOfMemory;
            input;
            Drive[] drives = null;
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("Please enter the letter of the drive, and press ENTER");
                input = Console.ReadLine();
                letterOfDrive = input[0];
                Console.WriteLine("Please enter the speed of drive in RPM, and press ENTER");
                input = Console.ReadLine();
                driveSpeedInRPM = int.Parse(input);
                Console.WriteLine("Please enter the amount of memory of drive in K, and press ENTER");
                input = Console.ReadLine();
                amountOfMemory = int.Parse(input);
                drives[i] = new Drive(driveSpeedInRPM, amountOfMemory, letterOfDrive);
            }
            int size;
            int resolutionX;
            int resolutionY;
            Monitor[] monitors = null;
            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("Please enter the size of the monitor in inch, and press ENTER");
                input = Console.ReadLine();
                size = int.Parse(input);
                Console.WriteLine("Please enter the resolution X of monitor, and press ENTER");
                input = Console.ReadLine();
                resolutionX = int.Parse(input);
                Console.WriteLine("Please enter the resolution Y of monitor, and press ENTER");
                input = Console.ReadLine();
                resolutionY = int.Parse(input);
                monitors[i] = new Monitor(size, resolutionX, resolutionY);
            }
            manufacturerName;
            modelName;
            int anountMemoryInRAM;
            Console.WriteLine("Please enter the name of manufacturer of the computer, and press ENTER");
            manufacturerName = Console.ReadLine();
            Console.WriteLine("Please enter the model of the computer, and press ENTER");
            modelName = Console.ReadLine();
            Console.WriteLine("Please enter the amount of memory in RAM of the computer, and press ENTER");
            input = Console.ReadLine();
            anountMemoryInRAM = int.Parse(input);
            //Computer computer;
            //computer = new Computer();
        }
    }
    class Drive
    {
        public int driveSpeedInRPM;
        public int amountOfMemory;
        public letterOfDrive;
        public Drive(int driveSpeedInRPM, int amountOfMemory, letterOfDrive)
        {
            this.driveSpeedInRPM = driveSpeedInRPM;
            this.amountOfMemory = amountOfMemory;
            this.letterOfDrive = letterOfDrive;
        }
        public void print()
        {
            Console.WriteLine("the drive: {0}, has {1} drive speed in RPM, and {2} amount of memory", this.letterOfDrive, this.driveSpeedInRPM, this.amountOfMemory);
        }
    }
    class Monitor
    {
        public int size;
        public int resolutionX;
        public int resolutionY;
        public Monitor(int size, int resolutionX, int resolutionY)
        {
            this.size = size;
            this.resolutionX = resolutionX;
            this.resolutionY = resolutionY;
        }
        public void print()
        {
            Console.WriteLine("the monitor has {0} inches, and the resolution is: {1} on {2}", this.size, this.resolutionX, this.resolutionY);
        }
    }
    class Computer
    {
        manufacturerName;
        modelName;
        int anountMemoryInRAM;
        Drive[] drives;
        Monitor[] monitors;
        public Computer( manufacturerName, modelName, int anountMemoryInRAM, Drive drive, Monitor monitor)
        {
            this.manufacturerName = manufacturerName;
            this.modelName = modelName;
            drives = new Drive[5];
            monitors = new Monitor[4];
            connectDrives(drive);
            connectMonitors(monitor);
        }
        public void connectDrives(Drive drive)
        {
            bool flag = true;
            for (int i = 0; i < 5 && flag; i++)
                if (drives[i] == null)
                {
                    drives[i] = drive;
                    flag = false;
                }
        }
        public void connectMonitors(Monitor monitor)
        {
            bool flag = true;
            for (int i = 0; i < 4 && flag; i++)
                if (monitors[i] == null)
                {
                    monitors[i] = monitor;
                    flag = false;
                }
        }
        public void print(Drive[] drives, Monitor[] monitors)
        {
            int count = 0;
            for (int i = 0; i < 5; i++)
            {
                if (drives[i] != null)
                    count++;
            }
            Console.WriteLine("the computer made by {0}, the model is: {1}, his memory is: {2} RAM. conected to him {3} drives:", this.manufacturerName, this.modelName, this.anountMemoryInRAM, count);
            for (int i = 0; i < 5; i++)
                if (drives[i] != null)
                    Console.WriteLine("{0}. {1}, has {2} drive speed in RPM, and {3} amount of memory.", i, drives[i].letterOfDrive, drives[i].driveSpeedInRPM, drives[i].amountOfMemory);
            count = 0;
            for (int i = 0; i < 4; i++)
            {
                if (monitors[i] != null)
                    count++;
            }
            Console.WriteLine("and conected to him {0} monitors:", count);
            for (int i = 0; i < 4; i++)
                if (monitors[i] != null)
                    Console.WriteLine("{0}, he has {1} inches, and the resolution is: {2} on {3}", i, monitors[i].size, monitors[i].resolutionX, monitors[i].resolutionY);
        }
    }



תוקן על ידי אנוני_מוס ב- 26/12/2013 09:34:33




דדווח על תוכן פוגעני

סמל אישי
מנותק
   
בית > פורומים > אינטרנט ומחשבים > למתכנתים שבינינו > תרגיל - מחשב
מנהל לחץ כאן לנעילת האשכול
הוסף לעמוד האישי  דווח למנהל שלח לחבר

bholext